@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maptiler/geocoding-control",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.44",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Martin Ždila",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
},
|
|
44
44
|
"types": "./dist/lib/index.d.ts",
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@sveltejs/vite-plugin-svelte": "^1.
|
|
46
|
+
"@sveltejs/vite-plugin-svelte": "^1.3.1",
|
|
47
47
|
"@tsconfig/svelte": "^3.0.0",
|
|
48
48
|
"@turf/buffer": "^6.5.0",
|
|
49
49
|
"@turf/difference": "^6.5.0",
|
|
50
50
|
"@turf/union": "^6.5.0",
|
|
51
51
|
"@types/leaflet": "^1.9.0",
|
|
52
|
-
"prettier": "^2.
|
|
52
|
+
"prettier": "^2.8.0",
|
|
53
53
|
"prettier-plugin-svelte": "^2.8.1",
|
|
54
54
|
"svelte": "^3.53.1",
|
|
55
55
|
"svelte-check": "^2.9.2",
|
|
@@ -33,10 +33,12 @@ export function createMaplibreglMapController(
|
|
|
33
33
|
showResultMarkers: boolean | maplibregl.MarkerOptions = true,
|
|
34
34
|
flyToOptions: FlyToOptions = {},
|
|
35
35
|
fitBoundsOptions: FitBoundsOptions = {},
|
|
36
|
-
fullGeometryStyle:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
fullGeometryStyle:
|
|
37
|
+
| undefined
|
|
38
|
+
| {
|
|
39
|
+
fill?: Pick<FillLayerSpecification, "layout" | "paint" | "filter">;
|
|
40
|
+
line?: Pick<LineLayerSpecification, "layout" | "paint" | "filter">;
|
|
41
|
+
} = {
|
|
40
42
|
fill: {
|
|
41
43
|
paint: {
|
|
42
44
|
"fill-color": "#000",
|
|
@@ -68,24 +70,30 @@ export function createMaplibreglMapController(
|
|
|
68
70
|
let selectedMarker: maplibregl.Marker | undefined;
|
|
69
71
|
|
|
70
72
|
function addFullGeometryLayer() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
if (fullGeometryStyle?.fill || fullGeometryStyle?.line) {
|
|
74
|
+
map.addSource("full-geom", {
|
|
75
|
+
type: "geojson",
|
|
76
|
+
data: emptyGeojson,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
75
79
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
if (fullGeometryStyle?.fill) {
|
|
81
|
+
map.addLayer({
|
|
82
|
+
...fullGeometryStyle?.fill,
|
|
83
|
+
id: "full-geom-fill",
|
|
84
|
+
type: "fill",
|
|
85
|
+
source: "full-geom",
|
|
86
|
+
});
|
|
87
|
+
}
|
|
82
88
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
if (fullGeometryStyle?.line) {
|
|
90
|
+
map.addLayer({
|
|
91
|
+
...fullGeometryStyle?.line,
|
|
92
|
+
id: "full-geom-line",
|
|
93
|
+
type: "line",
|
|
94
|
+
source: "full-geom",
|
|
95
|
+
});
|
|
96
|
+
}
|
|
89
97
|
}
|
|
90
98
|
|
|
91
99
|
if (map.loaded()) {
|
|
@@ -250,29 +258,33 @@ export function createMaplibreglMapController(
|
|
|
250
258
|
return; // no pin for (multi)linestrings
|
|
251
259
|
}
|
|
252
260
|
|
|
253
|
-
|
|
254
|
-
(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
+
if (showResultMarkers) {
|
|
262
|
+
markers.push(
|
|
263
|
+
(typeof marker === "object"
|
|
264
|
+
? new maplibregl.Marker(marker)
|
|
265
|
+
: createMarker()
|
|
266
|
+
)
|
|
267
|
+
.setLngLat(picked.center)
|
|
268
|
+
.addTo(map)
|
|
269
|
+
);
|
|
270
|
+
}
|
|
261
271
|
}
|
|
262
272
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
273
|
+
if (showResultMarkers) {
|
|
274
|
+
for (const feature of markedFeatures ?? []) {
|
|
275
|
+
if (feature === picked) {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
267
278
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
279
|
+
markers.push(
|
|
280
|
+
(typeof showResultMarkers === "object"
|
|
281
|
+
? new maplibregl.Marker(showResultMarkers)
|
|
282
|
+
: createMarker()
|
|
283
|
+
)
|
|
284
|
+
.setLngLat(feature.center)
|
|
285
|
+
.addTo(map)
|
|
286
|
+
);
|
|
287
|
+
}
|
|
276
288
|
}
|
|
277
289
|
},
|
|
278
290
|
|