Monday, December 10, 2018

drag drop popup leaflet js


Untuk melakukan draging popup bisa tambahkan fungsi berikut :


var makeDraggable=function (popup){      var pos = mymap.latLngToLayerPoint(popup.getLatLng());      L.DomUtil.setPosition(popup._wrapper.parentNode, pos);      var draggable = new L.Draggable(popup._container, popup._wrapper);      draggable.enable();           draggable.on('dragend', function() {        var pos = mymap.layerPointToLatLng(this._newPos);        popup.setLatLng(pos);      });    }



kemudian bisa dilakukan sbb :


marker.bindPopup('hello world');marker.on('click',function(event){                         var popup=event.target.getPopup();                               makeDraggable(popup);     })


No comments: