How to store e.latlng into array : leaflet

المشرف العام

Administrator
طاقم الإدارة
Introduction

I am working with leaflet api....where user can put markers on map...

I have made a custom button for putting marker...

Problem

I am willing to draw line between those markers i.e. using L.polylines().... but as i am new to javascript and leaflet i can't understand how to pass those latlng point to array which will later be used in these functions.... for initial working i have passed static coordinates(working as req)....

Script

L.easyButton('fa-link', function () {var secureThisArea = [[-81, 100.75], [-76.50, 245.75], [-145.50, 184.25], [-128, 311.75]]; map.on('click', function fencePlace(e) { L.marker([-81, 100.75], { icon: fenceIcon, draggable: true }).bindPopup("this is first").addTo(map); L.marker([-76.50, 245.75], { icon: fenceIcon, draggable: true }).bindPopup("this is second").addTo(map); L.marker([-145.50, 184.25], { icon: fenceIcon, draggable: true }).bindPopup("this is third").addTo(map); L.marker([-128, 311.75], { icon: fenceIcon, draggable: true }).bindPopup("this is fourth").addTo(map); L.polyline(secureThisArea).addTo(map);}); }).addTo(map);If someone can help, please do help,,,,, any kind of help or reference will be appreciated...thanks for your time(Down voters are welcome if they give reason too)



أكثر...
 
أعلى