Maybe I'm just tired and I'm missing something obvious.
This code using lat/long in one function works, zooms and center
properly:
<script>
var geocoder = null;
var map = null;
var bounds = new GLatLngBounds();
function load() {
if (GBrowserIsCompatible()) {
geocoder = new GClientGeocoder();
map = new GMap2(document.getElementById("gMap"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(0,0),0);
marker = new GMarker(new GLatLng(28.63961400, -81.389367));
map.addOverlay(marker);
bounds.extend(marker.getPoint());
marker = new GMarker(new GLatLng(34.05818, -118.25261));
map.addOverlay(marker);
bounds.extend(marker.getPoint());
marker = new GMarker(new GLatLng(34.04898, -118.25421));
map.addOverlay(marker);
bounds.extend(marker.getPoint());
marker = new GMarker(new GLatLng(34.04618, -118.25521));
map.addOverlay(marker);
bounds.extend(marker.getPoint());
map.setZoom(map.getBoundsZoomLevel(bounds));
map.setCenter(bounds.getCenter());
}
}
</script>
See here: http://vcigroupinc.no-ip.com/mapTest2.asp
But this code where I use an array of addresses and two functions
doesn't:
<script>
var arrAddress = ["1101 N. Lake Destiny Road, Maitland, FL 32751",
"224 Datura Street, West Palm Beach, FL 33401", "1451 W. Cypress Creek
Road, Ft. Lauderdale, FL 33309", "13101 Northwest Freeway, Houston, TX
77040"];
var geocoder = null;
var map = null;
var bounds = new GLatLngBounds();
function load() {
if (GBrowserIsCompatible()) {
geocoder = new GClientGeocoder();
map = new GMap2(document.getElementById("gMap"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.enableScrollWheelZoom();
map.setCenter(new GLatLng(0,0),0);
for (i=0; i<arrAddress.length; i++) {
geocoder.getLocations(arrAddress[i], addToMap);
}
map.setZoom(map.getBoundsZoomLevel(bounds));
map.setCenter(bounds.getCenter());
}
}
function addToMap(response) {
place = response.Placemark[0];
marker = new GMarker(new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]));
map.addOverlay(marker);
bounds.extend(marker.getPoint());
}
</script>
See here: http://vcigroupinc.no-ip.com/mapTest.asp
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" 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
-~----------~----~----~----~------~----~------~--~---