Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 13 additions & 9 deletions dist/OverPassLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ L.OverPassLayer = L.FeatureGroup.extend({
options: {
debug: false,
minzoom: 15,
requestPerTile: true,
endpoint: "http://overpass-api.de/api/",
query: "(node(BBOX)[organic];node(BBOX)[second_hand];);out qt;",
query: "(node({{bbox}})[organic];node({{bbox}})[second_hand];);out qt;",
callback: function(data) {
for(var i = 0; i < data.elements.length; i++) {
var e = data.elements[i];
Expand Down Expand Up @@ -224,12 +225,15 @@ L.OverPassLayer = L.FeatureGroup.extend({
}
//console.log(this._map.getBounds());
if (this._map.getZoom() >= this.options.minzoom) {
//var bboxList = new Array(this._map.getBounds());
var bboxList = this._view2BBoxes(
this._map.getBounds()._southWest.lng,
this._map.getBounds()._southWest.lat,
this._map.getBounds()._northEast.lng,
this._map.getBounds()._northEast.lat);
if (this.options.requestPerTile) {
var bboxList = this._view2BBoxes(
this._map.getBounds()._southWest.lng,
this._map.getBounds()._southWest.lat,
this._map.getBounds()._northEast.lng,
this._map.getBounds()._northEast.lat);
} else {
var bboxList = new Array(this._map.getBounds());
}

// controls the after/before (Request) callbacks
var finishedCount = 0;
Expand All @@ -250,7 +254,7 @@ L.OverPassLayer = L.FeatureGroup.extend({
this._requested[x][y] = true;


var queryWithMapCoordinates = this.options.query.replace(/(BBOX)/g, bbox.toOverpassBBoxString());
var queryWithMapCoordinates = this.options.query.replace(/(\{\{bbox\}\})/g, bbox.toOverpassBBoxString());
var url = this.options.endpoint + "interpreter?data=[out:json];" + queryWithMapCoordinates;

if (beforeRequest) {
Expand Down Expand Up @@ -294,7 +298,7 @@ L.OverPassLayer = L.FeatureGroup.extend({
}

this.onMoveEnd();
if (this.options.query.indexOf("(BBOX)") != -1) {
if (this.options.query.indexOf("({{bbox}})") != -1) {
map.on('moveend', this.onMoveEnd, this);
}
if (this.options.debug) {
Expand Down
2 changes: 1 addition & 1 deletion dist/OverPassLayer.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 13 additions & 9 deletions src/OverPassLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ L.OverPassLayer = L.FeatureGroup.extend({
options: {
debug: false,
minzoom: 15,
requestPerTile: true,
endpoint: "http://overpass-api.de/api/",
query: "(node(BBOX)[organic];node(BBOX)[second_hand];);out qt;",
query: "(node({{bbox}})[organic];node({{bbox}})[second_hand];);out qt;",
callback: function(data) {
for(var i = 0; i < data.elements.length; i++) {
var e = data.elements[i];
Expand Down Expand Up @@ -131,12 +132,15 @@ L.OverPassLayer = L.FeatureGroup.extend({
}
//console.log(this._map.getBounds());
if (this._map.getZoom() >= this.options.minzoom) {
//var bboxList = new Array(this._map.getBounds());
var bboxList = this._view2BBoxes(
this._map.getBounds()._southWest.lng,
this._map.getBounds()._southWest.lat,
this._map.getBounds()._northEast.lng,
this._map.getBounds()._northEast.lat);
if (this.options.requestPerTile) {
var bboxList = this._view2BBoxes(
this._map.getBounds()._southWest.lng,
this._map.getBounds()._southWest.lat,
this._map.getBounds()._northEast.lng,
this._map.getBounds()._northEast.lat);
} else {
var bboxList = new Array(this._map.getBounds());
}

// controls the after/before (Request) callbacks
var finishedCount = 0;
Expand All @@ -157,7 +161,7 @@ L.OverPassLayer = L.FeatureGroup.extend({
this._requested[x][y] = true;


var queryWithMapCoordinates = this.options.query.replace(/(BBOX)/g, bbox.toOverpassBBoxString());
var queryWithMapCoordinates = this.options.query.replace(/(\{\{bbox\}\})/g, bbox.toOverpassBBoxString());
var url = this.options.endpoint + "interpreter?data=[out:json];" + queryWithMapCoordinates;

if (beforeRequest) {
Expand Down Expand Up @@ -201,7 +205,7 @@ L.OverPassLayer = L.FeatureGroup.extend({
}

this.onMoveEnd();
if (this.options.query.indexOf("(BBOX)") != -1) {
if (this.options.query.indexOf("({{bbox}})") != -1) {
map.on('moveend', this.onMoveEnd, this);
}
if (this.options.debug) {
Expand Down