@maptiler/geocoding-control 0.0.43 → 0.0.44
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 -12
- package/dist/lib/maplibreglMapController.d.ts +3 -3
- package/dist/maplibregl.js +11 -10
- package/dist/maplibregl.umd.js +1 -1
- package/package.json +3 -3
- package/src/lib/maplibreglMapController.ts +52 -40
package/README.md
CHANGED
|
@@ -16,24 +16,20 @@ npm install --save @maptiler/geocoding-control maplibre-gl
|
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
18
|
import maplibregl from "maplibre-gl";
|
|
19
|
-
import { GeocodingControl } from "@maptiler/geocoding-control/
|
|
19
|
+
import { GeocodingControl } from "@maptiler/geocoding-control/maplibregl";
|
|
20
20
|
import "@maptiler/geocoding-control/dist/style.css";
|
|
21
|
+
import "maplibre-gl/dist/maplibre-gl.css";
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
+
const apiKey = "YOUR_MAPTILER_API_KEY_HERE";
|
|
23
24
|
|
|
24
25
|
const map = new maplibregl.Map({
|
|
25
26
|
container: "map", // id of HTML container element
|
|
26
|
-
style:
|
|
27
|
-
"https://api.maptiler.com/maps/streets/style.json?key=" +
|
|
28
|
-
YOUR_MAPTILER_API_KEY_HERE,
|
|
27
|
+
style: "https://api.maptiler.com/maps/streets/style.json?key=" + apiKey,
|
|
29
28
|
center: [16.3, 49.2],
|
|
30
29
|
zoom: 7,
|
|
31
30
|
});
|
|
32
31
|
|
|
33
|
-
const gc = new GeocodingControl({
|
|
34
|
-
apiKey: YOUR_MAPTILER_API_KEY_HERE,
|
|
35
|
-
maplibregl,
|
|
36
|
-
});
|
|
32
|
+
const gc = new GeocodingControl({ apiKey, maplibregl });
|
|
37
33
|
|
|
38
34
|
map.addControl(gc);
|
|
39
35
|
```
|
|
@@ -49,13 +45,14 @@ import * as L from "leaflet";
|
|
|
49
45
|
import { GeocodingControl } from "@maptiler/geocoding-control/leaflet";
|
|
50
46
|
import "@maptiler/geocoding-control/dist/style.css";
|
|
51
47
|
|
|
48
|
+
const apiKey = "YOUR_MAPTILER_API_KEY_HERE";
|
|
49
|
+
|
|
52
50
|
const map = L.map(document.getElementById("map")).setView([49.2, 16.3], 6);
|
|
53
51
|
|
|
54
52
|
const scale = devicePixelRatio > 1.5 ? "@2x" : "";
|
|
55
53
|
|
|
56
54
|
L.tileLayer(
|
|
57
|
-
`https://api.maptiler.com/maps/streets/{z}/{x}/{y}${scale}.png?key=` +
|
|
58
|
-
YOUR_MAPTILER_API_KEY_HERE,
|
|
55
|
+
`https://api.maptiler.com/maps/streets/{z}/{x}/{y}${scale}.png?key=` + apiKey,
|
|
59
56
|
{
|
|
60
57
|
tileSize: 512,
|
|
61
58
|
zoomOffset: -1,
|
|
@@ -67,7 +64,7 @@ L.tileLayer(
|
|
|
67
64
|
}
|
|
68
65
|
).addTo(map);
|
|
69
66
|
|
|
70
|
-
L.control.maptilerGeocoding({ apiKey
|
|
67
|
+
L.control.maptilerGeocoding({ apiKey }).addTo(map);
|
|
71
68
|
```
|
|
72
69
|
|
|
73
70
|
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:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type MapLibreGL from "maplibre-gl";
|
|
2
2
|
import type { FitBoundsOptions, Map, FlyToOptions, FillLayerSpecification, LineLayerSpecification } from "maplibre-gl";
|
|
3
3
|
import type { MapController } from "./types";
|
|
4
|
-
export declare function createMaplibreglMapController(map: Map, maplibregl?: typeof MapLibreGL | undefined, marker?: boolean | maplibregl.MarkerOptions, showResultMarkers?: boolean | maplibregl.MarkerOptions, flyToOptions?: FlyToOptions, fitBoundsOptions?: FitBoundsOptions, fullGeometryStyle?: {
|
|
5
|
-
fill
|
|
6
|
-
line
|
|
4
|
+
export declare function createMaplibreglMapController(map: Map, maplibregl?: typeof MapLibreGL | undefined, marker?: boolean | maplibregl.MarkerOptions, showResultMarkers?: boolean | maplibregl.MarkerOptions, flyToOptions?: FlyToOptions, fitBoundsOptions?: FitBoundsOptions, fullGeometryStyle?: undefined | {
|
|
5
|
+
fill?: Pick<FillLayerSpecification, "layout" | "paint" | "filter">;
|
|
6
|
+
line?: Pick<LineLayerSpecification, "layout" | "paint" | "filter">;
|
|
7
7
|
}): MapController;
|
package/dist/maplibregl.js
CHANGED
|
@@ -15233,16 +15233,16 @@ function $c(r, t, e = !0, n = !0, i = {}, o = {}, s = {
|
|
|
15233
15233
|
}) {
|
|
15234
15234
|
let a, u, l, c = [], f;
|
|
15235
15235
|
function h() {
|
|
15236
|
-
r.addSource("full-geom", {
|
|
15236
|
+
((s == null ? void 0 : s.fill) || (s == null ? void 0 : s.line)) && r.addSource("full-geom", {
|
|
15237
15237
|
type: "geojson",
|
|
15238
15238
|
data: ka
|
|
15239
|
-
}), r.addLayer({
|
|
15240
|
-
...s.fill,
|
|
15239
|
+
}), s != null && s.fill && r.addLayer({
|
|
15240
|
+
...s == null ? void 0 : s.fill,
|
|
15241
15241
|
id: "full-geom-fill",
|
|
15242
15242
|
type: "fill",
|
|
15243
15243
|
source: "full-geom"
|
|
15244
|
-
}), r.addLayer({
|
|
15245
|
-
...s.line,
|
|
15244
|
+
}), s != null && s.line && r.addLayer({
|
|
15245
|
+
...s == null ? void 0 : s.line,
|
|
15246
15246
|
id: "full-geom-line",
|
|
15247
15247
|
type: "line",
|
|
15248
15248
|
source: "full-geom"
|
|
@@ -15325,14 +15325,15 @@ function $c(r, t, e = !0, n = !0, i = {}, o = {}, s = {
|
|
|
15325
15325
|
return;
|
|
15326
15326
|
}
|
|
15327
15327
|
}
|
|
15328
|
-
c.push(
|
|
15328
|
+
n && c.push(
|
|
15329
15329
|
(typeof e == "object" ? new t.Marker(e) : N()).setLngLat(_.center).addTo(r)
|
|
15330
15330
|
);
|
|
15331
15331
|
}
|
|
15332
|
-
|
|
15333
|
-
C
|
|
15334
|
-
|
|
15335
|
-
|
|
15332
|
+
if (n)
|
|
15333
|
+
for (const C of d != null ? d : [])
|
|
15334
|
+
C !== _ && c.push(
|
|
15335
|
+
(typeof n == "object" ? new t.Marker(n) : N()).setLngLat(C.center).addTo(r)
|
|
15336
|
+
);
|
|
15336
15337
|
},
|
|
15337
15338
|
setSelectedMarker(d) {
|
|
15338
15339
|
f && f.getElement().classList.toggle("marker-selected", !1), f = d > -1 ? c[d] : void 0, f == null || f.getElement().classList.toggle("marker-selected", !0);
|