F
F
FalseCode2018-09-03 14:22:10
JavaScript
FalseCode, 2018-09-03 14:22:10

How to track active marker on google map?

There is a map. 5b8d1950aa6f2876146422.png It is necessary that by clicking on a certain marker information about the store is displayed in a separate block on the same page. At the moment I have implemented only clicks on the marker. Then I think to add an attribute to each marker and track which marker was clicked. But how to do this, I did not find the answer. Maybe someone came across tell me how to implement it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Justique, 2018-09-03
@FalseCode

var marker = new google.maps.Marker({
  position : latlng,
  map	: map,
  id : point.id //Тут идентификатор маркера
});

google.maps.event.addListener(marker, 'click', function() {
  console.log(marker.id);
  $('[data-id="'+marker.id+'"]').show(); //Показываем блок с информацией о этом маркере
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question