mirror of
https://github.com/owntracks/recorder.git
synced 2026-05-07 02:46:36 +00:00
Merge branch 'cocker-cc-Issue_267_swap_Lon_Lat'
This commit is contained in:
@@ -6,7 +6,7 @@ function initialize_leaflet() {
|
||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> 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 }}<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}})<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));
|
||||
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('<span class="latlon">{{ lat }},{{ lon }}</span>')}
|
||||
if(data.address) {text.push('{{ address }}')}
|
||||
if(data.vel !== undefined) {text.push('{{ vel }} km/h')}
|
||||
layer.bindPopup(Mustache.render(text.join('<br/>'), 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 ) {
|
||||
|
||||
Reference in New Issue
Block a user