I have a site which uses a google map, and works well, like this: http://www.railwaysarchive.co.uk/eventsummary.php?eventID=6689
I have built a version of that page which switches between OS maps and google maps, with the user able to choose which loads by default. It is here: http://www.railwaysarchive.co.uk/osmap/eventsummary.php?eventID=6689 The script uses a simple toggle as follows: function toggleMap() { // toggle map div visibility var googlemap = document.getElementById("googlemap"); var OSmap = document.getElementById("OSmap"); if (OSmap.style.display!="block") { // currently hidden, show OSmap.style.display="block"; googlemap.style.display="none"; document.getElementById("maplink").innerHTML= "Switch to Google Map"; } else { OSmap.style.display="none"; googlemap.style.display="block"; document.getElementById("maplink").innerHTML= "Switch to OS Map"; } } The user preference is set here: http://www.railwaysarchive.co.uk/osmap/preferences.php I was having trouble getting both maps to load their respective data when one was hidden, so both maps start out with display:block and then the gmap is hidden during the <body onload>. This system works great with Firefox and with Chrome, but in IE if the OS map is the default setting, when you switch to the google map the tiles don't load. If a GMap is to to default, it loads fine. Can anyone help? Relevant code snippets are as follows: function createAccidentSummaryMap(dblLatitude, dblLongitude, enumType, lngZoom) { // creates a map with a single event marker, map type controls and full zoom controls // and centers it on the event coordinates if (GBrowserIsCompatible()) { // checks for compatible browser map = new GMap2(document.getElementById("googlemap")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.addControl(new GScaleControl()); map.setCenter(new GLatLng(dblLatitude, dblLongitude), lngZoom); map.enableDoubleClickZoom(); // set map type based on cookie switch(getCookie("myMaps")) { case "GHyb": map.setMapType(G_HYBRID_MAP); break; case "GMap": map.setMapType(G_NORMAL_MAP); break; default: map.setMapType(G_SATELLITE_MAP); } var icon = createEventIcon(enumType); var point = new GLatLng(dblLatitude, dblLongitude); var marker = new GMarker(point, icon); map.addOverlay(marker); // } else { } } -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.
