diff --git a/docroot/map/map_leaflet.js b/docroot/map/map_leaflet.js
index aa42747..4c97c71 100644
--- a/docroot/map/map_leaflet.js
+++ b/docroot/map/map_leaflet.js
@@ -6,7 +6,7 @@ function initialize_leaflet() {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
-
+
var dataURL = location.protocol + "//" + location.host;
var parts = location.pathname.split('/');
@@ -31,41 +31,31 @@ function initialize_leaflet() {
features: []
};
- var geojsonLayer = new L.GeoJSON( empty_geojson , {
+ var geojsonLayer = new L.GeoJSON(empty_geojson, {
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, geojsonMarkerOptions);
},
onEachFeature: function(feature, layer) {
- if (feature.geometry.type == "Point") {
- var data ={}
- data.lat = feature.geometry.coordinates[0].toFixed(4);
- 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 }}
({{ lat }},{{lon}}) {{ fulldate }}
Speed: {{ speed }}";
- // if speed is 0 then don't display speed
- if (speed === 0) {
- t = "{{ addr }}
({{ lat }},{{lon}}) {{ fulldate }}"
- }
- if (typeof(tst) === 'undefined') {
- t = "Position: ({{lat}},{{lon}})
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));
+ if (feature.geometry.type == 'Point') {
+ var data ={};
+ data.address = feature.properties.address;
+ data.lat = feature.geometry.coordinates[1].toFixed(5);
+ data.lon = feature.geometry.coordinates[0].toFixed(5);
+ data.vel = feature.properties.vel;
+ data.tst = feature.properties.tst;
+ var localtime = moment.utc(data.tst * 1000).local();
+ data.timestring = localtime.format('YYYY-MM-DD, ddd, HH:mm:ss Z');
+
+ var text = [];
+ if(data.timestring) {text.push('{{ timestring }}')}
+ if(data.lat && data.lon) {text.push('{{ lat }},{{ lon }}')}
+ if(data.address) {text.push('{{ address }}')}
+ if(data.vel !== undefined) {text.push('{{ vel }} km/h')}
+ layer.bindPopup(Mustache.render(text.join('
'), data));
}
},
style : function(feature) {
- if (feature.geometry.type == "Point") {
+ if (feature.geometry.type == 'Point') {
return {}
} else {
return {
@@ -75,7 +65,7 @@ function initialize_leaflet() {
}
}
});
-
+
map.addLayer(geojsonLayer);
$.getJSON( dataURL, function( data ) {