Bear in mind that the map only has integer zoom levels available, so you can never get an "exact" fit. No "zoom = 1.5"
> var bounds = carte.getBounds(); > bounds.extend(location); > carte.fitBounds(bounds); Okay, so here you get the bounds of the existing map, extend it by the new marker, and fit-to-bounds. If the new marker is inside the old bounds, the fitting will make sure that the complete extent of the old map is contained within the new map - it will zoom out one level to _contain_ it, as you noticed. Solution : don't include the old map extent in your new bounds. You could do something like - After placing the new marker, test if there is only one marker so far. If so, use it to centre the map and set the zoom to some fixed level of your choice - to avoid the fit-to-bounds zooming in very close. If there is more than one marker, use all of them to create a new bounds object and use that to fit-to-bounds. To achieve that, you will probably have to keep some global array of markers, adding each one as it is created. -- 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.
