I’m wondering if there is a way to access the Markers that were added to a Map using JavaScript after creation.
I mean, is it possible to make a button somewhere on the page that, on each click, centers the map on another marker that was added previously?
Any help would really be appreciated!
Here’s one way.
Create an array of marker locations and add those to your array as you add the markers to the map. Associate the array index with your button and when the button is clicked, you can get your location from your array and centre on that.
Here’s a (very simple) example. The Javascript looks something like this:
and your HTML looks something like this: