Answer the question
In order to leave comments, you need to log in
How to find a marker on Google maps by coordinates or id?
There is the following situation.
Markers of certain points are plotted on Google maps.
There is also a list of these points.
<ul>
<li data-id='1' data-lat='...' data-lng='...'>point 1</li>
<li data-id='2' data-lat='...' data-lng='...'>point 2</li>
<li data-id='3' data-lat='...' data-lng='...'>point 3</li>
</ul>
Answer the question
In order to leave comments, you need to log in
Found a solution (I don't know how correct). All markers are an array. When clicking on an element of the list, I take the id value that corresponds to the array index, and the marker corresponds to it accordingly
$(document).on('click', '.selector', function(event) {
var id= $(this).data('id');
toggleBounce(markers[id]);
});
function toggleBounce(marker) {
if (marker.getAnimation() !== null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question