Answer the question
In order to leave comments, you need to log in
How to add double click handler to 2gis popup?
mounted(){
DG.then(() => {
this.map = DG.map('map-developer', {
center: [55.00545, 82.96038],
zoom: 14,
zoomControl: false,
minZoom: 11,
fullscreenControl: false,
scrollWheelZoom: false
});
this.markers = DG.featureGroup();
for (var i = 0; i < this.residentials.length; i++) {
const myDivIcon = DG.divIcon({
className: "marker-custom",
html: `<div class="marker-wrapper marker-active" data-id="${this.residentials[i].id}">
<div class="marker-content">
<div class="marker-title">${this.residentials[i].name}</div>
<div class="marker-address">${this.residentials[i].address}</div>
<div class="marker-decor"></div>
</div>
</div>`
});
const popupContent = `<div class="marker-wrapper popup-marker" data-id="${this.residentials[i].id}">
<div class="marker-content">
<div class="marker-title">${this.residentials[i].name}</div>
<div class="marker-address">${this.residentials[i].address}</div>
<div class="marker-decor"></div>
</div>
</div>`
const popupMap = DG.popup({ // для стилизации попапа нужно перебивать стоковые стили 2гис!
className: "test-name", // пустой класс для удаления стокового класса со стилями 2гис
closeButton: false,
offset: DG.point(0 ,10) // отступ ножки, в Px, находится подбором
}).setContent(popupContent).on('dblclick', (e) => { console.log('qqqqqqqqqqqqqq');});
DG.marker([this.residentials[i].latitude, this.residentials[i].longitude], { icon: myDivIcon })
.addTo(this.markers)
.bindPopup(popupMap).on('click', (event) => {
console.log('click: ');
if (event.originalEvent.target.closest("[data-id]")) {
const residentialId = Number(
event.originalEvent.target.closest("[data-id]").dataset.id
);
const route = this.residentials.find(rc => rc.id === residentialId).route;
this.$emit('click-marker', route);
}
// this.map.setView([event.latlng.lat, event.latlng.lng]);
}).on('dblclick', (event => {
console.log('dblclick: ', dblclick);
}))
}
DG.control.zoom({position: 'topright'}).addTo(this.map);
this.markers.addTo(this.map);
this.map.fitBounds(this.markers.getBounds());
});
}
.setContent(popupContent).on('dblclick', (e) => { console.log('qqqqqqqqqqqqqq');});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question