Merge pull request #246 from edautz/master

Added speed information to Openstreet map point
This commit is contained in:
JP Mens 2018-06-18 14:19:23 +02:00 committed by GitHub
commit 59c18af596
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,12 +42,23 @@ function initialize_leaflet() {
data.lon = feature.geometry.coordinates[1].toFixed(4);
data.addr = feature.properties.address;
var tst = feature.properties.tst;
// determine speed
data.speed = feature.properties.vel;
var speed = data.speed;
var dt = moment.utc(tst * 1000).local();
data.tst = tst;
data.fulldate = dt.format("DD MMM YYYY HH:mm:ss")
var t = "{{ addr }}<br/><span class='latlon'>({{ lat }},{{lon}})</span> {{ fulldate }}";
var t = "{{ addr }}<br/><span class='latlon'>({{ lat }},{{lon}})</span> {{ fulldate }}<br/> Speed: {{ speed }}";
// if speed is 0 then don't display speed
if (speed === 0) {
t = "{{ addr }}<br/><span class='latlon'>({{ lat }},{{lon}})</span> {{ fulldate }}"
}
if (typeof(tst) === 'undefined') {
t = "Position: {{lat}}, {{lon}}";
t = "Position: ({{lat}},{{lon}})<br/>Speed: {{speed}}";
}
// if speed is 0 then don't display speed
if (typeof(tst) === 'undefined' && speed === 0) {
t = "Position: ({{lat}},{{lon}})";
}
layer.bindPopup(Mustache.render(t, data));