perliedman / leaflet-realtime

Put realtime data on a Leaflet map
ISC License
737 stars 169 forks source link

Popup open automatically #143

Closed wanmad closed 5 years ago

wanmad commented 5 years ago

function createRealtimeLayer(url, container) { return L.realtime(url, { interval: 5 * 1000, getFeatureId: function(f) { return f.properties.url; }, cache: true, container: container, onEachFeature(f, l) { l.bindPopup(function() { return 'Device:' + f.properties.name + '
' + 'Status:' + f.properties.status+'
'+ 'Motion:' + f.properties.motion+'
'+ 'Last Update:' + f.properties.lastupdate + '
----------------------------------------
'+ 'Location: '+ f.properties.location+ '
Speed: ' + f.properties.speed + '' + '
' + f.properties.add1 + '' + '
' + f.properties.add2 + '' + '
' + f.properties.add3 + '' + '
More information'; }, {autoClose:false}).openPopup(); } }); }

var map = L.map('map'), clusterGroup = L.markerClusterGroup().addTo(map), subgroup1 = L.featureGroup.subGroup(clusterGroup), realtime1 = createRealtimeLayer('all.json.php', subgroup1).addTo(map);function

how to open popup automatically after marker load without user click marker?

perliedman commented 5 years ago

Hi, sorry this is not a question specific to Leaflet Realtime but rather how to use Leaflet's popups. openPopup should work if I remember correctly, but apparently some detail is missing in your code. Sad to say, I do not have the time to debug code (I do this in my quite limited free time), so I am going to close this.