javascript - Leaflet popup with live data -


i new using leaflet maps, , trying figure out way map display live data in popups. specifically, using current observations weather national weather service. right hard coding sites want use this:

var marker = l.marker([41.15789, -104.80812])      .bindpopup('site: cheyenne asos <br> <a href="http://w1.weather.gov/data/obhistory/kcys.html">current observations</a>')      .addto(map); 

i have 100 sites total. instead of user having click on website weather trying have displayed automatically when site clicked on. way show temperature, humidity, winds, etc.

if have insight or place find more information on appreciated!

if want dynamically insert data national weather service map, can use national weather service api

from there, can call api when page loads , put data in marker. can see how in leaflet documentation

for example, can do:

var popup = l.popup()     .setlatlng(latlng)     .setcontent('<p>insert html show weather info here</p>')     .openon(map); 

Comments