var map = L.map('map').setView([-6.935118, 107.766995], 15);
L.marker([-6.93155, 107.775831]).addTo(map)
.bindPopup('Bus Stops')
.openPopup();
I have this function on javascript, and I have a database that store the lat, lng, and the place name. Is there any possible way that I can do a loop so the marker is added automatically from what I have in my database? I’m using laravel blade. PS: its a leafletjs
3
Answers
Hmm, I’m not sure about that but you could try doing something like that
As well i can’t test it because i don’t have the code, It would be great if you added the variable
L
to the code so i can help you more with it.If the
L
is convertible toArray
or it’s already an array it should work.For more information about forEach loops check here!
If
L
is not an array you might need to addL.toArray().forEach
,You can follow this link to see prototypes for toArray() method.
you must get the all data and make it into Api
i make my Javascript like this
for Add Marker my Function Look Like This
First, modify your JS function to something similar to this:
For old versions of laravel:
For latest versions of laravel:
Then Loop through the array :