Skip to content

Commit

Permalink
[ui] Added "map/latlng/:latlng/:zoom" view
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Dec 18, 2017
1 parent 788253d commit 2466f0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions nodeshot/ui/default/static/ui/nodeshot/js/app.js
Expand Up @@ -119,9 +119,9 @@
},

// map node popup
getMapLatLng: function (latlng) {
getMapLatLng: function (latlng, zoom) {
this.getMap();
Ns.body.currentView.content.currentView.goToLatLng(latlng);
Ns.body.currentView.content.currentView.goToLatLng(latlng, zoom);
},

// layer list
Expand Down Expand Up @@ -193,6 +193,7 @@
'map': 'getMap',
'map/add': 'addNode',
'map/latlng/:latlng': 'getMapLatLng',
'map/latlng/:latlng/:zoom': 'getMapLatLng',
'map/:slug': 'getMapPopup',
'nodes': 'getNodeList',
'nodes/:slug': 'getNode',
Expand Down
12 changes: 8 additions & 4 deletions nodeshot/ui/default/static/ui/nodeshot/js/views/map.js
Expand Up @@ -580,16 +580,20 @@
/*
* Go to specified latitude and longitude
*/
goToLatLng: function (latlng) {
goToLatLng: function (latlng, zoom) {
latlng = latlng.split(',')
latlng = L.latLng(latlng[0], latlng[1]);
var self = this,
marker = L.marker(latlng);
marker.addTo(this.map);
// used in search address feature
if (!zoom) {
marker.addTo(this.map);
zoom = 18;
}
// go to marker and zoom in
this.map.setView(latlng, 18);
this.map.setView(latlng, zoom);
// fade out marker
if (typeof(marker) !== 'undefined') {
if (typeof(marker) !== 'undefined' && this.map.hasLayer(marker)) {
$([marker._icon, marker._shadow]).fadeOut(4000, function () {
self.map.removeLayer(marker);
});
Expand Down

0 comments on commit 2466f0a

Please sign in to comment.