Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
hopefully throttle api calls...
  • Loading branch information
v1r0x committed Feb 5, 2016
commit 5e3ddff5ba61125dbb18846f4ca0fe43d9a97103
66 changes: 34 additions & 32 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function debounce(func, wait, immediate) {

map.on('zoomend', function(e) {
var zoom = map.getZoom();
if(!$.jStorage.get('pois') || zoom < 9) return; //only show POIs on reasonable levels
if(!$.jStorage.get('pois') || zoom < 9) return false; //only show POIs on reasonable levels
Maps.displayPoiIcons(zoom);
})

Expand Down Expand Up @@ -912,37 +912,39 @@ function debounce(func, wait, immediate) {
traceDevice : null,
arrowHead : {},
displayPoiIcons : function(zoomLevel) {
$.each(poiLayers, function(i, layer) {
$.each(layer, function(group, values) {
$.each(values, function(j, value) {
var overpassLayer = new L.OverPassLayer({
minZoom: 9,
query: 'node({{bbox}})[' + group + '=' + value + '];out;',
onSuccess: function(data) {
for ( i = 0; i < data.elements.length; i++) {
e = data.elements[i];
if (e.id in this.instance._ids) {
return;
}
this.instance._ids[e.id] = true;
var pos = new L.LatLng(e.lat, e.lon);
var popup = Maps.getPoiPopupHTML(e.tags).innerHTML;
poiIcon = toolKit.getPoiIcon(value);
if (poiIcon) {
var marker = L.marker(pos, {
icon : poiIcon,
}).bindPopup(popup);
Maps.poiMarker.push(marker);
toolKit.addMarker(marker, popup)
}
}
}
});
map.addLayer(overpassLayer);
Maps.overpassLayers.push(overpassLayer);
});
});
});
$.each(poiLayers, function(i, layer) {
$.each(layer, function(group, values) {
$.each(values, function(j, value) {
setTimeout(function() {
var overpassLayer = new L.OverPassLayer({
minZoom: 9,
query: 'node({{bbox}})[' + group + '=' + value + '];out;',
onSuccess: function(data) {
for ( i = 0; i < data.elements.length; i++) {
e = data.elements[i];
if (e.id in this.instance._ids) {
return;
}
this.instance._ids[e.id] = true;
var pos = new L.LatLng(e.lat, e.lon);
var popup = Maps.getPoiPopupHTML(e.tags).innerHTML;
poiIcon = toolKit.getPoiIcon(value);
if (poiIcon) {
var marker = L.marker(pos, {
icon : poiIcon,
}).bindPopup(popup);
Maps.poiMarker.push(marker);
toolKit.addMarker(marker, popup)
}
}
}
});
map.addLayer(overpassLayer);
Maps.overpassLayers.push(overpassLayer);
}, 200);
});
});
});
},
hidePoiIcons : function() {
$.each(Maps.overpassLayers, function(i, layer) {
Expand Down