简体   繁体   中英

Google Maps API: How to Set Scroll Zoom to Anchor in on One Marker

I'm working on a project, where I need the scroll zoom to zoom in on a marker (or alternatively on a specific point), and not on my cursor as is the default. Currently the scroll zoom zooms in on the cursor. How can I achieve that?

You can try this

Set the center of you map"

center: new google.maps.LatLng(  ,  )

Then add function to move to marker position

google.maps.event.addListener(map, 'center_changed', function()
{

   map.panTo(marker.getPosition();

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM