简体   繁体   中英

Center map on a marker with the press of a button

How can I make my MapView focus on a specific Marker when a button is pressed?

I have a MapView with an array of markers and an array of buttons (there's the same number of markers and buttons), and I want to be able to focus an specific marker when one of those buttons is being pressed, and I also want the Callout inherent to that marker to show up as well.

How can I achieve this?

you can use ssociate the id of the button with the id of the marker, so when you onClick on your button, it will recognise the marker and so you need to do an animation for that.

document.getElementById("button"),
{
  zoom: 13,
  center: { lat: 59.325, lng: 18.07 },
}

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