A
A
Aleksander9112018-02-27 12:57:08
JavaScript
Aleksander911, 2018-02-27 12:57:08

How to move marker on hover?

Good day everyone!
Map 2Gis, there is a popup with information about the place.

DG.then(function() {
var map,
enabled = false;
map = DG.map('map', {
center: [43.824282, 131.906771],
zoom: 17,
animate: true
});


var mapDiv = document.getElementById('map');
mapDiv.style.height = ('620') + 'px';
// обновление карты
map.invalidateSize();

;

var popup = DG.popup({ 
    maxWidth: 450,
    minWidth: 380, 
    closeButton: false,
    className: 'regul-map',
    autoClose: false
    
    })
    .setLatLng([43.824282, 131.906771])
    .setContent('<div class="logo-map"></div><div class="map-content">\
  <div class="adress-map"><p>Город</p></div>\
  <div class="phone-map"><p>тел: 8(4321) 54-12-34</p><p>тел: 8(4321) 711-11-34</p></div>\
  <div class="time-map"><p>Время работы: 9:00 - 18:00</p></div>\
  </div>')
    .openOn(map);
  
  var marker = DG.marker({		
  })
  .setLatLng([43.824282, 131.906771])
  .addTo(map)
  .bindPopup(popup);
  
  marker.on('mouseover', function(ev) {
    popup.openOn(map);
    });	
  });

Tell me how to pass new coordinates from data attributes and show information when hovering over?
<p class="addres-data" data-lat="43.824282" data-lng="131.906771">Адрес</p>
<p class="addres-data" data-lat="37.582728" data-lng="55.781334">Адрес</p>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question