|
58 | 58 | // Custom methods
|
59 | 59 | //
|
60 | 60 | _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 |
| - }); |
87 | 61 | return L.Util.template(template, coords);
|
88 | 62 | },
|
89 | 63 |
|
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 |
| - |
101 | 64 | _updateTiles: function() {
|
102 | 65 | this.layer.clearLayers();
|
103 | 66 | this.features = {};
|
|
114 | 77 | geoData = geoData.features;
|
115 | 78 | }
|
116 | 79 | 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 |
| - } |
120 | 80 | var id = geoData[i].id;
|
121 | 81 | if (!this.features[id]) {
|
122 | 82 | this.layer.addData(geoData[i]);
|
|
0 commit comments