realtime don't update properties of geojson
See original GitHub issueHi! i use this code snippet to update my gps tracker data on map, everything working well besides that the geojson properties not being updated in the map. I show this properties with the OnEachFeature Option which called a function. This function creates a popup which shows the properties.
Now the problem…if the geojson is updated (position and properties) and the update is executed, only the position of the marker is updated, but not the properties in the popup. I have to reload the page to see the new properties.
How can i improve this?
function onEachFeature(feature, layer) {
if (feature.properties.course) {
popupContent = "Kurs: "+ feature.properties.course+" Grad <br>";
}
if (feature.properties.speed) {
popupContent += "Geschwindigkeit: "+ feature.properties.speed+" m/s <br>";
}
if (feature.properties.time) {
popupContent += "Zeit der GPS Daten: "+ feature.properties.time+"<br>";
}
layer.bindPopup(popupContent);
}
//initialisiere map
var mymap = L.map('mapid');
L.tileLayer.provider('Hydda.Full').addTo(mymap);
realtime = L.realtime(('http://myurl/position.geojson'), {
interval: 8 * 1000,
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, punktdef).bindTooltip("Tooltiptext");},
onEachFeature: onEachFeature,
}).addTo(mymap);
realtime.on('update', function() {
mymap.fitBounds(realtime.getBounds(), {maxZoom: 15});
});
this is the position.geojson example
{"properties": {"course": "87.0", "speed": "2.4", "time": "18:01:25 21.08.2018"}, "geometry": {"type": "Point", "coordinates": [18.578666632, 57.452197767]}, "type": "Feature"}
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Cool…it works… and so i was able to compare both and found the problem with your code above
the last “this” is wrong…if i remove that everything is ok
Thx, will try this