Hi I have sum wierd problems with my code..... Map is gray, and
centers on LA?

I can't get it to work Im building my map on top of other code which
makes it really ahrd to follow everything as i I'm quite new to google
maps API.

Is there anyone who has had this kind of trouble , and how do i solve
it?

var map;
var mgr;
var gdir;
var geocoder = null;
var addressMarker;
var icons = [];
var allmarkers_def = [];
var allmarkers = [];
if(CITY_MAP_CENTER_LAT=='')
{
        var CITY_MAP_CENTER_LAT = 34;
}
if(CITY_MAP_CENTER_LNG=='')
{
        var CITY_MAP_CENTER_LNG = 0;
}
if(CITY_MAP_CENTER_LAT!='' && CITY_MAP_CENTER_LNG!='' &&
CITY_MAP_ZOOMING_FACT!='')
{
        var CITY_MAP_ZOOMING_FACT = 13;
}else if(CITY_MAP_ZOOMING_FACT!='')
{
        var CITY_MAP_ZOOMING_FACT = 3;
}
if(CITY_MAP_VIEW_TYPE=='')
{
        var CITY_MAP_CENTER_LNG = 'G_NORMAL_MAP';
}
if(MAP_DISABLE_SCROLL_WHEEL_FLAG)
{
        var MAP_DISABLE_SCROLL_WHEEL_FLAG = 'No';
}
function initialize() {
if (GBrowserIsCompatible()) {
//var map = new GMap2(document.getElementById("map_canvas"));
gdir = new GDirections(map, document.getElementById("directions"));
GEvent.addListener(gdir, "load", onGDirectionsLoad);
GEvent.addListener(gdir, "error", handleErrors);

// Note that using Google Gears requires loading the Javascript
// at http://code.google.com/apis/gears/gears_init.js

var initialLocation;
var siberia = new google.maps.LatLng(60, 105);
var newyork = new google.maps.LatLng(40.69847032728747,
-73.9514422416687);
var browserSupportFlag =  new Boolean();

function initialize() {
  var myOptions = {
    zoom: 6,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);

  // Try W3C Geolocation (Preferred)
  if(navigator.geolocation) {
    browserSupportFlag = true;
    navigator.geolocation.getCurrentPosition(function(position) {
      initialLocation = new
google.maps.LatLng(position.coords.latitude,position.coords.longitude);
      map.setCenter(initialLocation);
    }, function() {
      handleNoGeolocation(browserSupportFlag);
    });
  // Try Google Gears Geolocation
  } else if (google.gears) {
    browserSupportFlag = true;
    var geo = google.gears.factory.create('beta.geolocation');
    geo.getCurrentPosition(function(position) {
      initialLocation = new
google.maps.LatLng(position.latitude,position.longitude);
      map.setCenter(initialLocation);
    }, function() {
      handleNoGeoLocation(browserSupportFlag);
    });
  // Browser doesn't support Geolocation
  } else {
    browserSupportFlag = false;
    handleNoGeolocation(browserSupportFlag);
  }

  function handleNoGeolocation(errorFlag) {
    if (errorFlag == true) {
      alert("Geolocation service failed.");
      initialLocation = newyork;
    } else {
      alert("Your browser doesn't support geolocation. We've placed
you in Siberia.");
      initialLocation = siberia;
    }
    map.setCenter(initialLocation);
  }
}


 var myLatlng = new google.maps.LatLng(33.956461,-118.396225);
  var myOptions = {
    zoom: 13,
    center: myLatlng,

  }
  var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}

function loadScript() {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.google.com/maps/api/js?
sensor=false&callback=initialize";
  document.body.appendChild(script);
}

window.onload = loadScript;


  var mapOptions = {
    googleBarOptions : {
      style : "new",
      adsOptions: {
        client: "partner-pub-7627771964347191",
        channel: "#8224075417",
        adsafe: "low",
        language: "sv"
      }
    }
  }

  //två rader med kommentarer
  //map = new GMap2(document.getElementById("map_canvas"),
mapOptions);
  //map.setCenter(new GLatLng(33.956461,-118.396225), 13);
  //map.setUIToDefault();
  var customUI = map.getDefaultUI();
  customUI.controls.scalecontrol = false;
  map.setUI(customUI);
  map.enableGoogleBar();
  //Geocoder
  geocoder = new GClientGeocoder();
  //Center on visitor
  //map.setCenter(new GLatLng(sGeobytesLatitude, sGeobytesLongitude),
11);
  GEvent.addListener(map, 'click', function(overlay, point) {
                var latLngStr = "Lat = " + point.y + ", Long = " + point.x;
                //map.openInfoWindow(point, latLngStr);
                document.getElementById("latbox").value=point.y;
                document.getElementById("lonbox").value=point.x;
        });
//Ta bort kommentar om du vill återgå till gamla mapcenter

//Här kommenterades en rad
//map.setCenter(new GLatLng(CITY_MAP_CENTER_LAT,CITY_MAP_CENTER_LNG),
CITY_MAP_ZOOMING_FACT);
//map.setCenter(new GLatLng(34, 0), 1);  //world map
//map.setUIToDefault(); //zooming icons

if(MAP_DISABLE_SCROLL_WHEEL_FLAG=='Yes')
{
        map.disableScrollWheelZoom();
}
if(CITY_MAP_VIEW_TYPE!='')
{
        map.setMapType(CITY_MAP_VIEW_TYPE);
}
mgr = new MarkerManager(map, {trackMarkers:true});
return map;
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API V2" group.
To post to this group, send email to google-maps-...@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-api+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en.

Reply via email to