support tiles in GeoJSON
This commit is contained in:
parent
2105d58961
commit
431c3d618b
1 changed files with 0 additions and 40 deletions
|
|
@ -58,46 +58,9 @@
|
|||
// Custom methods
|
||||
//
|
||||
_expandUrl: function(template, coords) {
|
||||
// from: https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Implementations
|
||||
var tile2lon = function(x,z) {
|
||||
return (x/Math.pow(2,z)*360-180);
|
||||
};
|
||||
var tile2lat = function(y,z) {
|
||||
var n=Math.PI-2*Math.PI*y/Math.pow(2,z);
|
||||
return (180/Math.PI*Math.atan(0.5*(Math.exp(n)-Math.exp(-n))));
|
||||
};
|
||||
// from: https://leafletjs.com/reference-1.5.0.html#map-methods-for-getting-map-state
|
||||
var southWest = L.latLng(
|
||||
tile2lat(coords.y+1, coords.z),
|
||||
tile2lon(coords.x+1, coords.z)
|
||||
);
|
||||
var northEast = L.latLng(
|
||||
tile2lat(coords.y, coords.z),
|
||||
tile2lon(coords.x, coords.z)
|
||||
);
|
||||
// from: "toBBoxString()" on https://leafletjs.com/reference-1.5.0.html#latlngbounds
|
||||
var bboxStr = [southWest.lng,southWest.lat,northEast.lng,northEast.lat].join(',');
|
||||
coords = Object.assign(coords, {
|
||||
lat1: southWest.lat,
|
||||
lon1: southWest.lng,
|
||||
lat2: northEast.lat,
|
||||
lon2: northEast.lng,
|
||||
bbox: bboxStr
|
||||
});
|
||||
return L.Util.template(template, coords);
|
||||
},
|
||||
|
||||
_hashCode: function(str) {
|
||||
var hash = 0, i, chr;
|
||||
if (str.length === 0) return hash;
|
||||
for (i = 0; i < str.length; i++) {
|
||||
chr = str.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + chr;
|
||||
hash |= 0; // Convert to 32bit integer
|
||||
}
|
||||
return hash;
|
||||
},
|
||||
|
||||
_updateTiles: function() {
|
||||
this.layer.clearLayers();
|
||||
this.features = {};
|
||||
|
|
@ -114,9 +77,6 @@
|
|||
geoData = geoData.features;
|
||||
}
|
||||
for (var i=0;i<geoData.length;i++) {
|
||||
if (!geoData[i].id) {
|
||||
geoData[i].id = this._hashCode(JSON.stringify(geoData[i].geometry));
|
||||
}
|
||||
var id = geoData[i].id;
|
||||
if (!this.features[id]) {
|
||||
this.layer.addData(geoData[i]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue