This would be the basic approach // Make a bounds object var bounds = new google.maps.LatLngBounds();
// Feed your bounds object with your points bounds.extend(points); // Call fitBounds() so that the map viewport fits the bounds map.fitBounds(bounds); On Jul 10, 12:52 am, Lennart K <[email protected]> wrote: > Hello, > Still working with my maps of recovered ringed birds I really got > stuck with the construction of dynamic maps, adjusted to the locations > of recoveries for different bird species - some are all i Europe, some > extend to southern Africa. I want the bounds and the zoom level of the > maps to be set according to these variations. > Data are taken from a mysql-db and thus it's easy to get the > coordinates for the bounds of the maps for a selected species by > selecting the max/min latitudes and logitudes respectively. You can > then get the SW and NE corners and by adding/subtracting one or two > degrees you may avoid to get the markers in the very corners. > Example: > SW=43.883331, -3.116667; > NE=61.483334, 24.383333; > This should be put into a new google.maps.LatLngBounds(), shouldn't > it? > Please show me the exact syntax for this. > And then you should use setCenter(something) to get the center of the > map, shouldn't you? > Then the latlng of the required center position would be fullfilled. > > Now I want to bring this into the initialization of the map. > > The static map initialization is: > var latlng = new google.maps.LatLng(48.130000, 25.570000); > var myOptions = { > zoom: 4, > center: latlng, > mapTypeId: google.maps.MapTypeId.HYBRID > }; > var map = new google.maps.Map(document.getElementById("map_canvas"), > myOptions); > > So - I should replace the LatLng(48.130000, 25.570000) with WHAT? > and I should replace zoom: 4 with WHAT? > I have made several attempts to get around this - but I'm probably too > unfamiliar with javascript to figure it out. I would welcome every > help with this matter. > Thank you > Lennarthttp://www.skof.se/fbo/aterfynd/min_phpsqlajax_map3.php -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" 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-js-api-v3?hl=en.
