diff --git a/lib/map.js b/lib/map.js index 665b8bb..28eab04 100644 --- a/lib/map.js +++ b/lib/map.js @@ -396,8 +396,8 @@ define(['map/clientlayer', 'map/labelslayer', } function mapRTree(d) { - var o = [d.nodeinfo.location.latitude, d.nodeinfo.location.longitude, - d.nodeinfo.location.latitude, d.nodeinfo.location.longitude]; + var o = { minX: d.nodeinfo.location.latitude, minY: d.nodeinfo.location.longitude, + maxX: d.nodeinfo.location.latitude, maxY: d.nodeinfo.location.longitude }; o.node = d; diff --git a/lib/map/labelslayer.js b/lib/map/labelslayer.js index 910421a..c7aefbb 100644 --- a/lib/map/labelslayer.js +++ b/lib/map/labelslayer.js @@ -22,7 +22,7 @@ define(['leaflet', 'rbush', 'helper'], } function mapRTree(d) { - var o = [d.position.lat, d.position.lng, d.position.lat, d.position.lng]; + var o = { minX: d.position.lat, minY: d.position.lng, maxX: d.position.lat, maxY: d.position.lng }; o.label = d; @@ -72,7 +72,7 @@ define(['leaflet', 'rbush', 'helper'], var x = p.x + offset[0] + dx[anchor[0]]; var y = p.y + offset[1] + dy[anchor[1]]; - return [x, y, x + width, y + height]; + return { minX: x, minY: y, maxX: x + width, maxY: y + height }; } return L.TileLayer.Canvas.extend({ @@ -124,8 +124,7 @@ define(['leaflet', 'rbush', 'helper'], function nodeToRect(z) { return function (n) { var p = map.project(n.position, z); - return [p.x - nodeRadius, p.y - nodeRadius, - p.x + nodeRadius, p.y + nodeRadius]; + return { minX: p.x - nodeRadius, minY: p.y - nodeRadius, maxX: p.x + nodeRadius, maxY: p.y + nodeRadius }; }; } @@ -206,9 +205,7 @@ define(['leaflet', 'rbush', 'helper'], } var bbox = helper.getTileBBox(s, map, tileSize, this.margin); - var labels = this.labels.search(bbox).map(projectNodes); - var ctx = canvas.getContext('2d'); ctx.lineWidth = 5; diff --git a/lib/utils/helper.js b/lib/utils/helper.js index cbf6411..46f1d97 100644 --- a/lib/utils/helper.js +++ b/lib/utils/helper.js @@ -194,6 +194,6 @@ define({ var tl = map.unproject([s.x - margin, s.y - margin]); var br = map.unproject([s.x + margin + tileSize, s.y + margin + tileSize]); - return [br.lat, tl.lng, tl.lat, br.lng]; + return { minX: br.lat, minY: tl.lng, maxX: tl.lat, maxY: br.lng }; } }); diff --git a/package.json b/package.json index 0afece8..cca58fd 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "moment": "^2.17.1", "node-polyglot": "^2.2.2", "promise-polyfill": "^6.0.2", - "rbush": "1.4.3", + "rbush": "^2.0.1", "requirejs": "^2.3.2", "virtual-dom": "^2.1.1" } diff --git a/yarn.lock b/yarn.lock index e807993..1a08d1d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2810,6 +2810,10 @@ qs@~5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/qs/-/qs-5.1.0.tgz#4d932e5c7ea411cca76a312d39a606200fd50cd9" +quickselect@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-1.0.0.tgz#02630818f9aae4ecab26f0103f98d061c17c58f3" + randomatic@^1.1.3: version "1.1.6" resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb" @@ -2829,9 +2833,11 @@ raw-body@~2.1.5: iconv-lite "0.4.13" unpipe "1.0.0" -rbush@1.4.3: - version "1.4.3" - resolved "https://registry.yarnpkg.com/rbush/-/rbush-1.4.3.tgz#7874e2d38911d2719ea27731d32445da5ec4394c" +rbush@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/rbush/-/rbush-2.0.1.tgz#4cfaca28c3064bc0ee75431a1b79990e875eefa9" + dependencies: + quickselect "^1.0.0" rc@~1.1.6: version "1.1.6"