@maptiler/geocoding-control 0.0.31 → 0.0.36
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 +32 -18
- package/dist/leaflet.js +346 -339
- package/dist/leaflet.umd.cjs +1 -1
- package/dist/lib/LeafletGeocodingControl.d.ts +1 -1
- package/dist/lib/MaplibreglGeocodingControl.d.ts +1 -1
- package/dist/lib/maplibreglMapController.d.ts +4 -0
- package/dist/lib/types.d.ts +3 -1
- package/dist/main.d.ts +1 -1
- package/dist/maplibregl.js +2046 -652
- package/dist/maplibregl.umd.cjs +22 -1
- package/dist/style.css +1 -1
- package/package.json +8 -5
- package/src/lib/GeocodingControl.svelte +44 -8
- package/src/lib/LeafletGeocodingControl.ts +16 -3
- package/src/lib/MaplibreglGeocodingControl.ts +4 -5
- package/src/lib/maplibreglMapController.ts +282 -0
- package/src/lib/types.ts +3 -1
- package/dist/lib/LeafletMapControllerImpl.d.ts +0 -3
- package/dist/lib/MaplibreMapControllerImpl.d.ts +0 -4
- package/src/lib/maplibreMapController.ts +0 -149
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MapTiler Geocoding control for MapLibre GL JS and Leaflet
|
|
2
2
|
|
|
3
|
-
A geocoding control for [
|
|
3
|
+
A geocoding control for [Maplibre GL JS](https://github.com/maplibre/maplibre-gl-js) and [Leaflet](https://github.com/maplibre/maplibre-gl-js).
|
|
4
4
|
|
|
5
5
|
Component can be used as ES module or UMD module.
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ Component can be used as ES module or UMD module.
|
|
|
8
8
|
|
|
9
9
|
### Usage with a module bundler
|
|
10
10
|
|
|
11
|
-
Example for
|
|
11
|
+
Example for Maplibre GL JS:
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
npm install --save @maptiler/geocoding-control maplibre-gl
|
|
@@ -19,24 +19,26 @@ import maplibregl from "maplibre-gl";
|
|
|
19
19
|
import { GeocodingControl } from "@maptiler/geocoding-control/maplibre";
|
|
20
20
|
import "@maptiler/geocoding-control/dist/style.css";
|
|
21
21
|
|
|
22
|
-
const API_KEY = "
|
|
22
|
+
const API_KEY = "YOUR_MAPTILER_API_KEY_HERE";
|
|
23
23
|
|
|
24
24
|
const map = new maplibregl.Map({
|
|
25
25
|
container: "map", // id of HTML container element
|
|
26
|
-
style:
|
|
26
|
+
style:
|
|
27
|
+
"https://api.maptiler.com/maps/streets/style.json?key=" +
|
|
28
|
+
YOUR_MAPTILER_API_KEY_HERE,
|
|
27
29
|
center: [16.3, 49.2],
|
|
28
30
|
zoom: 7,
|
|
29
31
|
});
|
|
30
32
|
|
|
31
33
|
const gc = new GeocodingControl({
|
|
32
|
-
apiKey:
|
|
34
|
+
apiKey: YOUR_MAPTILER_API_KEY_HERE,
|
|
33
35
|
maplibregl,
|
|
34
36
|
});
|
|
35
37
|
|
|
36
38
|
map.addControl(gc);
|
|
37
39
|
```
|
|
38
40
|
|
|
39
|
-
Example for
|
|
41
|
+
Example for Leaflet:
|
|
40
42
|
|
|
41
43
|
```bash
|
|
42
44
|
npm install --save @maptiler/geocoding-control leaflet
|
|
@@ -47,19 +49,31 @@ import * as L from "leaflet";
|
|
|
47
49
|
import { GeocodingControl } from "@maptiler/geocoding-control/leaflet";
|
|
48
50
|
import "@maptiler/geocoding-control/dist/style.css";
|
|
49
51
|
|
|
50
|
-
const API_KEY = "your API key";
|
|
51
|
-
|
|
52
52
|
const map = L.map(document.getElementById("map")).setView([49.2, 16.3], 6);
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
54
|
+
const scale = devicePixelRatio > 1.5 ? "@2x" : "";
|
|
55
|
+
|
|
56
|
+
L.tileLayer(
|
|
57
|
+
`https://api.maptiler.com/maps/streets/{z}/{x}/{y}${scale}.png?key=` +
|
|
58
|
+
YOUR_MAPTILER_API_KEY_HERE,
|
|
59
|
+
{
|
|
60
|
+
tileSize: 512,
|
|
61
|
+
zoomOffset: -1,
|
|
62
|
+
minZoom: 1,
|
|
63
|
+
attribution:
|
|
64
|
+
'<a href="https://www.maptiler.com/copyright/" target="_blank">© MapTiler</a>, ' +
|
|
65
|
+
'<a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap contributors</a>',
|
|
66
|
+
crossOrigin: true,
|
|
67
|
+
}
|
|
68
|
+
).addTo(map);
|
|
58
69
|
|
|
59
|
-
|
|
70
|
+
L.control.maptilerGeocoding({ apiKey: YOUR_MAPTILER_API_KEY_HERE }).addTo(map);
|
|
60
71
|
```
|
|
61
72
|
|
|
62
|
-
|
|
73
|
+
For examples without using bundler see `demo-maplibregl.html` or `demo-leaflet.html`. After building this library (`npm install && npm run build`) you can open it in the browser:
|
|
74
|
+
|
|
75
|
+
- Maplibre GL JS: `sensible-browser file://$(pwd)/demo-maplibregl.html#key=YOUR_MAPTILER_API_KEY_HERE`
|
|
76
|
+
- Leaflet: `sensible-browser file://$(pwd)/demo-leaflet.html#key=YOUR_MAPTILER_API_KEY_HERE`
|
|
63
77
|
|
|
64
78
|
## API Documentation
|
|
65
79
|
|
|
@@ -114,12 +128,12 @@ Component API matches API described above and options are exposed as component p
|
|
|
114
128
|
<script lang="ts">
|
|
115
129
|
import GeocodingControl from "@maptiler/geocoding-control/src/lib/GeocodingControl.svelte";
|
|
116
130
|
import GeocodingControl from "@maptiler/geocoding-control/src/lib/GeocodingControl.svelte";
|
|
117
|
-
import {
|
|
131
|
+
import { createMaplibreglMapController } from "@maptiler/geocoding-control/src/lib/maplibreglMapController";
|
|
118
132
|
import type { MapController } from "@maptiler/geocoding-control/src/lib/types";
|
|
119
133
|
import maplibregl from "maplibre-gl";
|
|
120
134
|
import "maplibre-gl/dist/maplibre-gl.css";
|
|
121
135
|
|
|
122
|
-
const apiKey = "
|
|
136
|
+
const apiKey = "YOUR_MAPTILER_API_KEY_HERE";
|
|
123
137
|
|
|
124
138
|
let mapController: MapController;
|
|
125
139
|
|
|
@@ -132,7 +146,7 @@ Component API matches API described above and options are exposed as component p
|
|
|
132
146
|
container,
|
|
133
147
|
});
|
|
134
148
|
|
|
135
|
-
const mapController =
|
|
149
|
+
const mapController = createMaplibreglMapController(map, maplibregl);
|
|
136
150
|
}
|
|
137
151
|
</script>
|
|
138
152
|
|
|
@@ -161,5 +175,5 @@ You will find compilation result in `dist` directory.
|
|
|
161
175
|
## Running in dev mode
|
|
162
176
|
|
|
163
177
|
```bash
|
|
164
|
-
npm install && VITE_API_KEY=
|
|
178
|
+
npm install && VITE_API_KEY=YOUR_MAPTILER_API_KEY_HERE npm run dev
|
|
165
179
|
```
|