1
0
Fork 0

Show position map only when we have coordinates

merge-requests/142/head
Nikos Roussos 2017-03-13 12:48:48 +02:00
parent 47e0a741b9
commit ec295d3711
No known key found for this signature in database
GPG Key ID: BADFF1767BA7C8E1
1 changed files with 31 additions and 28 deletions

View File

@ -8,38 +8,41 @@ $(document).ready(function() {
var lat = $('.satellite-title').data('position-lat');
var lon = $('.satellite-title').data('position-lon');
L.mapbox.accessToken = mapboxtoken;
L.mapbox.config.FORCE_HTTPS = true;
var map = L.mapbox.map('map', mapboxid, {
zoomControl: false
}).setView([lat, lon], 3);
if (lat && lon) {
var myLayer = L.mapbox.featureLayer().addTo(map);
L.mapbox.accessToken = mapboxtoken;
L.mapbox.config.FORCE_HTTPS = true;
var map = L.mapbox.map('map', mapboxid, {
zoomControl: false
}).setView([lat, lon], 3);
var geojson = {
type: 'FeatureCollection',
features: [{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [lon, lat]
},
'properties': {
'icon': {
'iconUrl': '/static/img/satellite-marker.png',
'iconSize': [32, 32],
'iconAnchor': [16, 16],
var myLayer = L.mapbox.featureLayer().addTo(map);
var geojson = {
type: 'FeatureCollection',
features: [{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [lon, lat]
},
'properties': {
'icon': {
'iconUrl': '/static/img/satellite-marker.png',
'iconSize': [32, 32],
'iconAnchor': [16, 16],
}
}
}
}]
};
}]
};
myLayer.on('layeradd', function(e) {
var marker = e.layer,
feature = marker.feature;
myLayer.on('layeradd', function(e) {
var marker = e.layer,
feature = marker.feature;
marker.setIcon(L.icon(feature.properties.icon));
});
marker.setIcon(L.icon(feature.properties.icon));
});
myLayer.setGeoJSON(geojson);
myLayer.setGeoJSON(geojson);
}
});