I'm using the Google Maps API. When I click on a map marker, I want the map to zoom in one step, but maintain the marker's position relative to the window.
This is similar to when you use the mouse wheel to zoom: the zooming is towards the current cursor position.
The map.setZoom() function zooms relative to the center of the map. This is not what I want.
Can't find any simple solution to this, anyone has a clue?
Hy please try this. Automatically zooming marker.
float zoomLevel = 16.0; //This goes up to 21
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoomLevel));
This kind of works, not an elegant solution:
function zoomInAtMarker(marker)
{
var pos = marker.getPosition();
var bounds = map.getBounds();
map.setZoom(map.getZoom() + 1);
var span = map.getBounds().toSpan();
var s = pos.lat() - span.lat() * (pos.lat() - bounds.getSouthWest().lat()) / bounds.toSpan().lat();
var w = pos.lng() - span.lng() * (pos.lng() - bounds.getSouthWest().lng()) / bounds.toSpan().lng();
map.panToBounds({ south:s, north:s + span.lat(), west:w, east:w + span.lng()});
}