@india-boundary-corrector/leaflet-layer 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -20
- package/dist/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +13 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.js +1 -0
package/README.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# @india-boundary-corrector/leaflet-layer
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@india-boundary-corrector/leaflet-layer)
|
|
4
|
+
|
|
3
5
|
Leaflet TileLayer extension that automatically applies India boundary corrections.
|
|
4
6
|
|
|
7
|
+
[Try it on JSFiddle](https://jsfiddle.net/z8d76em5/1/)
|
|
8
|
+
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
7
11
|
```bash
|
|
@@ -26,7 +30,7 @@ No bundler required! Just include the script and use the global `IndiaBoundaryCo
|
|
|
26
30
|
IndiaBoundaryCorrector.extendLeaflet(L);
|
|
27
31
|
|
|
28
32
|
// Create map
|
|
29
|
-
const map = L.map('map').setView([
|
|
33
|
+
const map = L.map('map').setView([33.2778, 75.3412], 5);
|
|
30
34
|
|
|
31
35
|
// Use corrected tile layer - config auto-detected from URL
|
|
32
36
|
L.tileLayer.indiaBoundaryCorrected('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
@@ -45,7 +49,7 @@ import { extendLeaflet } from '@india-boundary-corrector/leaflet-layer';
|
|
|
45
49
|
extendLeaflet(L);
|
|
46
50
|
|
|
47
51
|
// Create map
|
|
48
|
-
const map = L.map('map').setView([
|
|
52
|
+
const map = L.map('map').setView([33.2778, 75.3412], 5);
|
|
49
53
|
|
|
50
54
|
// Use corrected tile layer - config auto-detected from URL
|
|
51
55
|
L.tileLayer.indiaBoundaryCorrected('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
@@ -61,12 +65,12 @@ import { extendLeaflet, layerConfigs } from '@india-boundary-corrector/leaflet-l
|
|
|
61
65
|
|
|
62
66
|
extendLeaflet(L);
|
|
63
67
|
|
|
64
|
-
const map = L.map('map').setView([
|
|
68
|
+
const map = L.map('map').setView([33.2778, 75.3412], 5);
|
|
65
69
|
|
|
66
70
|
// Use a specific config by ID
|
|
67
71
|
L.tileLayer.indiaBoundaryCorrected('https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png', {
|
|
68
72
|
layerConfig: 'cartodb-dark',
|
|
69
|
-
attribution: '©
|
|
73
|
+
attribution: '© CARTO © OpenStreetMap contributors'
|
|
70
74
|
}).addTo(map);
|
|
71
75
|
```
|
|
72
76
|
|
|
@@ -78,7 +82,7 @@ import { extendLeaflet, LayerConfig } from '@india-boundary-corrector/leaflet-la
|
|
|
78
82
|
|
|
79
83
|
extendLeaflet(L);
|
|
80
84
|
|
|
81
|
-
const map = L.map('map').setView([
|
|
85
|
+
const map = L.map('map').setView([33.2778, 75.3412], 5);
|
|
82
86
|
|
|
83
87
|
// Create custom config
|
|
84
88
|
const osmDeConfig = new LayerConfig({
|
|
@@ -134,21 +138,6 @@ layer.on('correctionerror', (e) => {
|
|
|
134
138
|
| `coords` | object | Tile coordinates `{ z, x, y }` |
|
|
135
139
|
| `tileUrl` | string | URL of the tile being loaded |
|
|
136
140
|
|
|
137
|
-
## Global Auto-extension
|
|
138
|
-
|
|
139
|
-
If Leaflet is available as a global `L` object, the extension is applied automatically on import:
|
|
140
|
-
|
|
141
|
-
```html
|
|
142
|
-
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
|
|
143
|
-
<script type="module">
|
|
144
|
-
import '@india-boundary-corrector/leaflet-layer';
|
|
145
|
-
|
|
146
|
-
// L.TileLayer.IndiaBoundaryCorrected is now available
|
|
147
|
-
const map = L.map('map').setView([20.5937, 78.9629], 5);
|
|
148
|
-
L.tileLayer.indiaBoundaryCorrected('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
|
|
149
|
-
</script>
|
|
150
|
-
```
|
|
151
|
-
|
|
152
141
|
## License
|
|
153
142
|
|
|
154
143
|
Unlicense
|
package/dist/index.cjs
CHANGED
|
@@ -2677,7 +2677,7 @@ function applyMedianBlurAlongPath(ctx, features, lineWidth, tileSize, maskCanvas
|
|
|
2677
2677
|
if (!maskCanvas || maskCanvas.width !== tileSize || maskCanvas.height !== tileSize) {
|
|
2678
2678
|
maskCanvas = new OffscreenCanvas(tileSize, tileSize);
|
|
2679
2679
|
}
|
|
2680
|
-
const maskCtx = maskCanvas.getContext("2d");
|
|
2680
|
+
const maskCtx = maskCanvas.getContext("2d", { willReadFrequently: true });
|
|
2681
2681
|
maskCtx.fillStyle = "black";
|
|
2682
2682
|
maskCtx.fillRect(0, 0, tileSize, tileSize);
|
|
2683
2683
|
maskCtx.strokeStyle = "white";
|
|
@@ -2879,8 +2879,11 @@ var BoundaryCorrector = class {
|
|
|
2879
2879
|
const useOsm = zoom >= zoomThreshold;
|
|
2880
2880
|
const addLayerName = useOsm ? "to-add-osm" : "to-add-ne";
|
|
2881
2881
|
const delLayerName = useOsm ? "to-del-osm" : "to-del-ne";
|
|
2882
|
-
|
|
2883
|
-
|
|
2882
|
+
if (!this._canvas || this._canvas.width !== tileSize) {
|
|
2883
|
+
this._canvas = new OffscreenCanvas(tileSize, tileSize);
|
|
2884
|
+
}
|
|
2885
|
+
const canvas = this._canvas;
|
|
2886
|
+
const ctx = canvas.getContext("2d", { willReadFrequently: true });
|
|
2884
2887
|
const blob = new Blob([rasterTile]);
|
|
2885
2888
|
const imageBitmap = await createImageBitmap(blob);
|
|
2886
2889
|
ctx.drawImage(imageBitmap, 0, 0, tileSize, tileSize);
|