Introduction:
I have to implement the custom control to draw a polygon which should be bound with marker, i.e marker should move along the polygon lines .....
I have setup some work but can't find further help so came here...
Script
var myMovingMarker; var latlng; //animated marker L.easyButton('fa-bicycle', function () { map.on('click', function (e) { latlng = [[51.509, -0.08],[51.503, -0.06],[51.51, -0.047],[51.51, -0.047]]; myMovingMarker = L.Marker.movingMarker(latlng[]],[20000], { icon: customIcons }).addTo(map); L.polygon(latlng[]).addTo(map); myMovingMarker.start(); }); }).addTo(map);
أكثر...
I am working with the leaflet api, i have implemented a script which will put marker on map(onClick) and animate marker to the position i have set.....
Problem
I have to implement the custom control to draw a polygon which should be bound with marker, i.e marker should move along the polygon lines .....
I had one choice of L.polygon(latlng[],option).addTo(map); but can't find the way to store the latlng points in array onClick so the polygon could be drawn,,, and then passing these latlng array to myAnimatedMarker.....
Like: i need to store the point in array
var latlng = [[51.509, -0.08],[51.503, -0.06],[51.51, -0.047],[51.51, -0.047]]; L.polygon(latlng[]).addTo(map);
I dont now other way around.....Like: i need to store the point in array
var latlng = [[51.509, -0.08],[51.503, -0.06],[51.51, -0.047],[51.51, -0.047]]; L.polygon(latlng[]).addTo(map);
I have setup some work but can't find further help so came here...
Script
var myMovingMarker; var latlng; //animated marker L.easyButton('fa-bicycle', function () { map.on('click', function (e) { latlng = [[51.509, -0.08],[51.503, -0.06],[51.51, -0.047],[51.51, -0.047]]; myMovingMarker = L.Marker.movingMarker(latlng[]],[20000], { icon: customIcons }).addTo(map); L.polygon(latlng[]).addTo(map); myMovingMarker.start(); }); }).addTo(map);
So if i use the current method, i will need to store the e.latlng in array on click(dont know how to do this, couldn't get help) and the other way i been searching and asking for help....
If someone can help, please do help....Any kind of help or reference will be appreciated....Thanks for your time.
أكثر...