When the user changes the bounds, the map is centered back on userPinLoc.

Which is some externally provided position. The map will just center on that.

It takes no account of the nearestEntitiesToZoom data, that you used
to create the bounds.

ie. having worked out the bounds they wont affect userPinLoc

Maybe you intended:

google.maps.event.addDomListener(googleMap, 'bounds_changed', function() {
            googleMap.setCenter(bounds.getCenter());
});


??


On Mon, Jan 23, 2012 at 9:42 AM, faisal.khan <[email protected]> wrote:
> I wrote the following function to to fit visible all pushpins(Auto
> zoom to fit all pushpins) along user's location @ center
>
> but problem is " googleMap.setCenter(userPinLoc);" makes few pins out
> of view port.
>
> I can i set fitbounds and telling that "userPinLoc" must be center and
> rest of around also visible.
>
> function setInitialZoom() {
>        mapZoom = googleMap.getZoom();
>        var bounds = new google.maps.LatLngBounds();
>        bounds.extend(userPinLoc);
>        for (i in nearestEntitiesToZoom) {
>            entity = nearestEntitiesToZoom[i];
>            var googleLatLng = new
> google.maps.LatLng(entity.latitude,entity.longitude);
>            bounds.extend(googleLatLng);
>        }
>
>        google.maps.event.addDomListener(googleMap, 'bounds_changed',
> function() {
>            googleMap.setCenter(userPinLoc);
>        });
>
>        googleMap.fitBounds(bounds);
>
>    }
>
> --
> 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.
>

-- 
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.

Reply via email to