Skip to content

Commit 431c3d6

Browse files
committed
support tiles in GeoJSON
1 parent 2105d58 commit 431c3d6

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

examples/clients/leaflet/geojson-tile-layer.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -58,46 +58,9 @@
5858
// Custom methods
5959
//
6060
_expandUrl: function(template, coords) {
61-
// from: https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Implementations
62-
var tile2lon = function(x,z) {
63-
return (x/Math.pow(2,z)*360-180);
64-
};
65-
var tile2lat = function(y,z) {
66-
var n=Math.PI-2*Math.PI*y/Math.pow(2,z);
67-
return (180/Math.PI*Math.atan(0.5*(Math.exp(n)-Math.exp(-n))));
68-
};
69-
// from: https://leafletjs.com/reference-1.5.0.html#map-methods-for-getting-map-state
70-
var southWest = L.latLng(
71-
tile2lat(coords.y+1, coords.z),
72-
tile2lon(coords.x+1, coords.z)
73-
);
74-
var northEast = L.latLng(
75-
tile2lat(coords.y, coords.z),
76-
tile2lon(coords.x, coords.z)
77-
);
78-
// from: "toBBoxString()" on https://leafletjs.com/reference-1.5.0.html#latlngbounds
79-
var bboxStr = [southWest.lng,southWest.lat,northEast.lng,northEast.lat].join(',');
80-
coords = Object.assign(coords, {
81-
lat1: southWest.lat,
82-
lon1: southWest.lng,
83-
lat2: northEast.lat,
84-
lon2: northEast.lng,
85-
bbox: bboxStr
86-
});
8761
return L.Util.template(template, coords);
8862
},
8963

90-
_hashCode: function(str) {
91-
var hash = 0, i, chr;
92-
if (str.length === 0) return hash;
93-
for (i = 0; i < str.length; i++) {
94-
chr = str.charCodeAt(i);
95-
hash = ((hash << 5) - hash) + chr;
96-
hash |= 0; // Convert to 32bit integer
97-
}
98-
return hash;
99-
},
100-
10164
_updateTiles: function() {
10265
this.layer.clearLayers();
10366
this.features = {};
@@ -114,9 +77,6 @@
11477
geoData = geoData.features;
11578
}
11679
for (var i=0;i<geoData.length;i++) {
117-
if (!geoData[i].id) {
118-
geoData[i].id = this._hashCode(JSON.stringify(geoData[i].geometry));
119-
}
12080
var id = geoData[i].id;
12181
if (!this.features[id]) {
12282
this.layer.addData(geoData[i]);

0 commit comments

Comments
 (0)