@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maptiler/geocoding-control",
3
- "version": "0.0.43",
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.2.0",
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.7.1",
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
- fill: Pick<FillLayerSpecification, "layout" | "paint" | "filter">;
38
- line: Pick<LineLayerSpecification, "layout" | "paint" | "filter">;
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
- map.addSource("full-geom", {
72
- type: "geojson",
73
- data: emptyGeojson,
74
- });
73
+ if (fullGeometryStyle?.fill || fullGeometryStyle?.line) {
74
+ map.addSource("full-geom", {
75
+ type: "geojson",
76
+ data: emptyGeojson,
77
+ });
78
+ }
75
79
 
76
- map.addLayer({
77
- ...fullGeometryStyle.fill,
78
- id: "full-geom-fill",
79
- type: "fill",
80
- source: "full-geom",
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
- map.addLayer({
84
- ...fullGeometryStyle.line,
85
- id: "full-geom-line",
86
- type: "line",
87
- source: "full-geom",
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
- markers.push(
254
- (typeof marker === "object"
255
- ? new maplibregl.Marker(marker)
256
- : createMarker()
257
- )
258
- .setLngLat(picked.center)
259
- .addTo(map)
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
- for (const feature of markedFeatures ?? []) {
264
- if (feature === picked) {
265
- continue;
266
- }
273
+ if (showResultMarkers) {
274
+ for (const feature of markedFeatures ?? []) {
275
+ if (feature === picked) {
276
+ continue;
277
+ }
267
278
 
268
- markers.push(
269
- (typeof showResultMarkers === "object"
270
- ? new maplibregl.Marker(showResultMarkers)
271
- : createMarker()
272
- )
273
- .setLngLat(feature.center)
274
- .addTo(map)
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