New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

leaflet-virtual-grid

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaflet-virtual-grid - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

leaflet-virtual-grid-v1.0.5.zip

5

CHANGELOG.md

@@ -8,2 +8,6 @@ # Change Log

## [1.0.5]
* ES6 Leaflet imports (courtesy of [@finneganh](https://github.com/finneganh))
## [1.0.4]

@@ -48,2 +52,3 @@

[Unreleased]: https://github.com/patrickarlt/leaflet-virtual-grid/compare/v1.0.4...HEAD
[1.0.5]: https://github.com/patrickarlt/leaflet-virtual-grid/compare/v1.0.4...v1.0.5
[1.0.4]: https://github.com/patrickarlt/leaflet-virtual-grid/compare/v1.0.3...v1.0.4

@@ -50,0 +55,0 @@ [1.0.3]: https://github.com/patrickarlt/leaflet-virtual-grid/compare/v1.0.2...v1.0.3

60

dist/virtual-grid.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('leaflet')) :
typeof define === 'function' && define.amd ? define(['leaflet'], factory) :
global.VirtualGrid = factory(global.L);
}(this, function (L) { 'use strict';
global.VirtualGrid = factory(global.leaflet);
}(this, function (leaflet) { 'use strict';
L = 'default' in L ? L['default'] : L;
var VirtualGrid = leaflet.Layer.extend({
var VirtualGrid = L.Layer.extend({
options: {

@@ -17,3 +15,3 @@ cellSize: 512,

initialize: function (options) {
options = L.setOptions(this, options);
options = leaflet.setOptions(this, options);
this._zooming = false;

@@ -24,3 +22,3 @@ },

this._map = map;
this._update = L.Util.throttle(this._update, this.options.updateInterval, this);
this._update = leaflet.Util.throttle(this._update, this.options.updateInterval, this);
this._reset();

@@ -104,9 +102,9 @@ this._update();

var bounds = this._map.getPixelBounds();
var mapBounds = this._map.getPixelBounds();
var cellSize = this._getCellSize();
// cell coordinates range for the current view
var cellBounds = L.bounds(
bounds.min.divideBy(cellSize).floor(),
bounds.max.divideBy(cellSize).floor());
var cellBounds = leaflet.bounds(
mapBounds.min.divideBy(cellSize).floor(),
mapBounds.max.divideBy(cellSize).floor());

@@ -119,5 +117,5 @@ this._removeOtherCells(cellBounds);

_addCells: function (bounds) {
_addCells: function (cellBounds) {
var queue = [];
var center = bounds.getCenter();
var center = cellBounds.getCenter();
var zoom = this._map.getZoom();

@@ -127,5 +125,5 @@

// create a queue of coordinates to load cells from
for (j = bounds.min.y; j <= bounds.max.y; j++) {
for (i = bounds.min.x; i <= bounds.max.x; i++) {
coords = L.point(i, j);
for (j = cellBounds.min.y; j <= cellBounds.max.y; j++) {
for (i = cellBounds.min.x; i <= cellBounds.max.x; i++) {
coords = leaflet.point(i, j);
coords.z = zoom;

@@ -161,6 +159,6 @@

// don't load cell if it's out of bounds and not wrapped
var bounds = this._cellNumBounds;
var cellNumBounds = this._cellNumBounds;
if (
(!crs.wrapLng && (coords.x < bounds.min.x || coords.x > bounds.max.x)) ||
(!crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.max.y))
(!crs.wrapLng && (coords.x < cellNumBounds.min.x || coords.x > cellNumBounds.max.x)) ||
(!crs.wrapLat && (coords.y < cellNumBounds.min.y || coords.y > cellNumBounds.max.y))
) {

@@ -177,3 +175,3 @@ return false;

var cellBounds = this._cellCoordsToBounds(coords);
return L.latLngBounds(this.options.bounds).intersects(cellBounds);
return leaflet.latLngBounds(this.options.bounds).intersects(cellBounds);
},

@@ -190,3 +188,3 @@

return L.latLngBounds(nw, se);
return leaflet.latLngBounds(nw, se);
},

@@ -205,3 +203,3 @@

return L.point(x, y);
return leaflet.point(x, y);
},

@@ -237,11 +235,11 @@

for (var key in this._cells) {
var bounds = this._cells[key].bounds;
var cellBounds = this._cells[key].bounds;
var coords = this._cells[key].coords;
if (this.cellLeave) {
this.cellLeave(bounds, coords);
this.cellLeave(cellBounds, coords);
}
this.fire('cellleave', {
bounds: bounds,
bounds: cellBounds,
coords: coords

@@ -298,4 +296,4 @@ });

_wrapCoords: function (coords) {
coords.x = this._wrapLng ? L.Util.wrapNum(coords.x, this._wrapLng) : coords.x;
coords.y = this._wrapLat ? L.Util.wrapNum(coords.y, this._wrapLat) : coords.y;
coords.x = this._wrapLng ? leaflet.Util.wrapNum(coords.x, this._wrapLng) : coords.x;
coords.y = this._wrapLat ? leaflet.Util.wrapNum(coords.y, this._wrapLat) : coords.y;
},

@@ -305,8 +303,8 @@

_getCellNumBounds: function () {
var bounds = this._map.getPixelWorldBounds();
var worldBounds = this._map.getPixelWorldBounds();
var size = this._getCellSize();
return bounds ? L.bounds(
bounds.min.divideBy(size).floor(),
bounds.max.divideBy(size).ceil().subtract([1, 1])) : null;
return worldBounds ? leaflet.bounds(
worldBounds.min.divideBy(size).floor(),
worldBounds.max.divideBy(size).ceil().subtract([1, 1])) : null;
}

@@ -313,0 +311,0 @@ });

{
"name": "leaflet-virtual-grid",
"version": "1.0.4",
"version": "1.0.5",
"description": "A lightweight DOM-less tile layer for Leaflet that can be used to query APIs with bounding boxes or center/radius as opposed to loading tiles.",

@@ -9,3 +9,3 @@ "main": "dist/virtual-grid.js",

"lint": "semistandard --verbose | snazzy",
"test": "npm run lint && browserify test/virtual-grid.js -t [ babelify --presets es2015 ] | tape-run --browser phantom | faucet",
"test": "npm run lint && browserify test/virtual-grid.js -t [ babelify --presets es2015 ] | tape-run | faucet",
"bundle": "rollup src/virtual-grid.js -m dist/virtual-grid.js.map -e leaflet -f umd -o dist/virtual-grid.js -n VirtualGrid",

@@ -41,3 +41,2 @@ "release": "scripts/release.sh",

"isparta": "^4.0.0",
"phantomjs": "^2.1.7",
"rollup": "^0.21.0",

@@ -52,4 +51,4 @@ "semistandard": "^7.0.2",

"dependencies": {
"leaflet": "^1.0.0-rc.1"
"leaflet": "^1.0.0"
}
}

@@ -1,4 +0,11 @@

import L from 'leaflet';
import {
bounds,
latLngBounds,
point,
Layer,
setOptions,
Util
} from 'leaflet';
var VirtualGrid = L.Layer.extend({
var VirtualGrid = Layer.extend({

@@ -11,3 +18,3 @@ options: {

initialize: function (options) {
options = L.setOptions(this, options);
options = setOptions(this, options);
this._zooming = false;

@@ -18,3 +25,3 @@ },

this._map = map;
this._update = L.Util.throttle(this._update, this.options.updateInterval, this);
this._update = Util.throttle(this._update, this.options.updateInterval, this);
this._reset();

@@ -98,9 +105,9 @@ this._update();

var bounds = this._map.getPixelBounds();
var mapBounds = this._map.getPixelBounds();
var cellSize = this._getCellSize();
// cell coordinates range for the current view
var cellBounds = L.bounds(
bounds.min.divideBy(cellSize).floor(),
bounds.max.divideBy(cellSize).floor());
var cellBounds = bounds(
mapBounds.min.divideBy(cellSize).floor(),
mapBounds.max.divideBy(cellSize).floor());

@@ -113,5 +120,5 @@ this._removeOtherCells(cellBounds);

_addCells: function (bounds) {
_addCells: function (cellBounds) {
var queue = [];
var center = bounds.getCenter();
var center = cellBounds.getCenter();
var zoom = this._map.getZoom();

@@ -121,5 +128,5 @@

// create a queue of coordinates to load cells from
for (j = bounds.min.y; j <= bounds.max.y; j++) {
for (i = bounds.min.x; i <= bounds.max.x; i++) {
coords = L.point(i, j);
for (j = cellBounds.min.y; j <= cellBounds.max.y; j++) {
for (i = cellBounds.min.x; i <= cellBounds.max.x; i++) {
coords = point(i, j);
coords.z = zoom;

@@ -155,6 +162,6 @@

// don't load cell if it's out of bounds and not wrapped
var bounds = this._cellNumBounds;
var cellNumBounds = this._cellNumBounds;
if (
(!crs.wrapLng && (coords.x < bounds.min.x || coords.x > bounds.max.x)) ||
(!crs.wrapLat && (coords.y < bounds.min.y || coords.y > bounds.max.y))
(!crs.wrapLng && (coords.x < cellNumBounds.min.x || coords.x > cellNumBounds.max.x)) ||
(!crs.wrapLat && (coords.y < cellNumBounds.min.y || coords.y > cellNumBounds.max.y))
) {

@@ -171,3 +178,3 @@ return false;

var cellBounds = this._cellCoordsToBounds(coords);
return L.latLngBounds(this.options.bounds).intersects(cellBounds);
return latLngBounds(this.options.bounds).intersects(cellBounds);
},

@@ -184,3 +191,3 @@

return L.latLngBounds(nw, se);
return latLngBounds(nw, se);
},

@@ -199,3 +206,3 @@

return L.point(x, y);
return point(x, y);
},

@@ -231,11 +238,11 @@

for (var key in this._cells) {
var bounds = this._cells[key].bounds;
var cellBounds = this._cells[key].bounds;
var coords = this._cells[key].coords;
if (this.cellLeave) {
this.cellLeave(bounds, coords);
this.cellLeave(cellBounds, coords);
}
this.fire('cellleave', {
bounds: bounds,
bounds: cellBounds,
coords: coords

@@ -292,4 +299,4 @@ });

_wrapCoords: function (coords) {
coords.x = this._wrapLng ? L.Util.wrapNum(coords.x, this._wrapLng) : coords.x;
coords.y = this._wrapLat ? L.Util.wrapNum(coords.y, this._wrapLat) : coords.y;
coords.x = this._wrapLng ? Util.wrapNum(coords.x, this._wrapLng) : coords.x;
coords.y = this._wrapLat ? Util.wrapNum(coords.y, this._wrapLat) : coords.y;
},

@@ -299,8 +306,8 @@

_getCellNumBounds: function () {
var bounds = this._map.getPixelWorldBounds();
var worldBounds = this._map.getPixelWorldBounds();
var size = this._getCellSize();
return bounds ? L.bounds(
bounds.min.divideBy(size).floor(),
bounds.max.divideBy(size).ceil().subtract([1, 1])) : null;
return worldBounds ? bounds(
worldBounds.min.divideBy(size).floor(),
worldBounds.max.divideBy(size).ceil().subtract([1, 1])) : null;
}

@@ -307,0 +314,0 @@ });

import VirtualGrid from '../src/virtual-grid.js';
import test from 'tape-catch';
import sinon from 'sinon';
import L from 'leaflet';
import { map, point } from 'leaflet';

@@ -16,3 +16,3 @@ function createMap () {

return L.map(container);
return map(container);
}

@@ -42,3 +42,3 @@

grid.on('cellsupdated', function () {
t.ok(grid.createCell.getCall(0).args[1].equals(L.point([0, 0])));
t.ok(grid.createCell.getCall(0).args[1].equals(point([0, 0])));
map.remove();

@@ -59,8 +59,8 @@ });

grid.on('cellsupdated', function () {
t.ok(grid.cellLeave.getCall(0).args[1].equals(L.point([0, 0, 1])));
t.ok(grid.cellLeave.getCall(0).args[1].equals(point([0, 0, 1])));
t.ok(grid.createCell.getCall(1).args[1].equals(L.point([0, 0, 2])));
t.ok(grid.createCell.getCall(2).args[1].equals(L.point([1, 0, 2])));
t.ok(grid.createCell.getCall(3).args[1].equals(L.point([0, 1, 2])));
t.ok(grid.createCell.getCall(4).args[1].equals(L.point([1, 1, 2])));
t.ok(grid.createCell.getCall(1).args[1].equals(point([0, 0, 2])));
t.ok(grid.createCell.getCall(2).args[1].equals(point([1, 0, 2])));
t.ok(grid.createCell.getCall(3).args[1].equals(point([0, 1, 2])));
t.ok(grid.createCell.getCall(4).args[1].equals(point([1, 1, 2])));

@@ -82,4 +82,4 @@ map.remove();

grid.on('cellsupdated', function () {
t.ok(grid.createCell.getCall(4).args[1].equals(L.point([5, 4, 4])));
t.ok(grid.createCell.getCall(5).args[1].equals(L.point([4, 5, 4])));
t.ok(grid.createCell.getCall(4).args[1].equals(point([5, 4, 4])));
t.ok(grid.createCell.getCall(5).args[1].equals(point([4, 5, 4])));
map.remove();

@@ -86,0 +86,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc