Last active
March 12, 2019 09:54
-
-
Save avilaj/5079833 to your computer and use it in GitHub Desktop.
This is an attempt to make the foursquare layer implementation for leafletjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Jorge Avila <jorge.e.avila@gmail.com> | |
* @license Mit | |
* @description Adds a padding to one side of the layer, like foursquare does. | |
*/ | |
// i use the nwtjs library to get the element and height | |
// you can modify it to use jquery or whatever... instead | |
updateExtended = function () { | |
if (!this._map) { return; } | |
var bounds = this._map.getPixelBounds(), | |
zoom = this._map.getZoom(), | |
tileSize = this.options.tileSize; | |
if (zoom > this.options.maxZoom || zoom < this.options.minZoom) { | |
return; | |
} | |
el = n.one('html'); | |
documentWidth = el.region().width; | |
difference = Math.round (el.region().width - documentWidth); | |
var nwTilePoint = new L.Point( | |
Math.floor((bounds.min.x - difference) / tileSize), | |
Math.floor(bounds.min.y / tileSize)), | |
seTilePoint = new L.Point( | |
Math.floor(bounds.max.x / tileSize), | |
Math.floor(bounds.max.y / tileSize)), | |
tileBounds = new L.Bounds(nwTilePoint, seTilePoint); | |
this._addTilesFromCenterOut(tileBounds); | |
if (this.options.unloadInvisibleTiles || this.options.reuseTiles) { | |
this._removeOtherTiles(tileBounds); | |
} | |
}; | |
L.TileLayer.APP = L.TileLayer.extend({_update:updateExt}); | |
L.tileLayer.app = function (url, options) { | |
new L.TileLayer.APP (url, options); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment