You can use the fitBounds method for this.

a) create a bounds object: var bounds = new
google.maps.LatLngBounds();

b) each time you place a new marker (polyline/polygon, circle/
rectangle overlay etc). extend the bounds object by its lat,lng.;e.g.
        var markerLatLng = new google.maps.LatLng(52.02235, 8.54339);
        var marker = new google.maps.Marker({
         position: markerLatLng,
         title: 'my new marker',
         map: map
        });
        bounds.extend(markerLatLng);

c) call map.fitBounds(bounds) at the end on your map object

Cheers




On 28 Okt., 18:57, dupablada <skea...@gmail.com> wrote:
> Hi there.
>
> I'm pretty new to all this and have managed to bash together a google
> map that pulls address locations from a mysql database.
>
> I wanting to know though if I can set the map to centre automatically
> over the place marks?
>
> At the moment it is set to always show a specified area.
>
> So if I for instance had a bunch of place marks in London it would zoom
> in and show the area that has place marks. If I then added a place mark
> in scotland it would then zoom out when the page was loaded to show the
> whole of the UK.
>
> I figured I need to do something with the map.setCenter
>
> Any help with this would be appreciated.

-- 
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 google-maps-js-api...@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to