@maptiler/geocoding-control 0.0.82 → 0.0.84

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.
@@ -0,0 +1,14 @@
1
+ import type { Feature, FeatureCollection } from "./types";
2
+ export type DispatcherType = {
3
+ featuresListed: Feature[];
4
+ featuresMarked: Feature[];
5
+ optionsVisibilityChange: boolean;
6
+ pick: Feature;
7
+ queryChange: string;
8
+ response: {
9
+ url: string;
10
+ featureCollection: FeatureCollection;
11
+ };
12
+ reverseToggle: boolean;
13
+ select: Feature;
14
+ };
@@ -1,9 +1,8 @@
1
1
  <script>import { createEventDispatcher } from "svelte";
2
2
  import { onDestroy } from "svelte/internal";
3
- import ReverseGeocodingIcon from "./ReverseGeocodingIcon.svelte";
4
3
  import ClearIcon from "./ClearIcon.svelte";
5
4
  import LoadingIcon from "./LoadingIcon.svelte";
6
- import MarkerIcon from "./MarkerIcon.svelte";
5
+ import ReverseGeocodingIcon from "./ReverseGeocodingIcon.svelte";
7
6
  import SearchIcon from "./SearchIcon.svelte";
8
7
  let className = undefined;
9
8
  export { className as class };
@@ -259,7 +258,10 @@ async function search(searchValue, { byId = false, exact = false, } = {}) {
259
258
  });
260
259
  }
261
260
  catch (e) {
262
- if (e && typeof e === "object" && e.name === "AbortError") {
261
+ if (e &&
262
+ typeof e === "object" &&
263
+ "name" in e &&
264
+ e.name === "AbortError") {
263
265
  return;
264
266
  }
265
267
  throw new Error();
@@ -682,4 +684,9 @@ function unwrapBbox(bbox0) {
682
684
  form.can-collapse:hover :not(:nth-of-type(1)) {
683
685
  opacity: 1;
684
686
  }
687
+
688
+ :global(.maplibregl-ctrl-geocoder) {
689
+ position: relative;
690
+ z-index: 3;
691
+ }
685
692
  </style>
@@ -1,5 +1,5 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import type { Feature, FeatureCollection, MapController, Proximity } from "./types";
2
+ import type { Feature, MapController, Proximity } from "./types";
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  class?: string | undefined;
@@ -37,17 +37,14 @@ declare const __propDef: {
37
37
  setQuery?: ((value: string, submit?: boolean) => void) | undefined;
38
38
  };
39
39
  events: {
40
- select: CustomEvent<Feature>;
41
- pick: CustomEvent<Feature>;
42
- optionsVisibilityChange: CustomEvent<boolean>;
43
- featuresListed: CustomEvent<Feature[]>;
44
- featuresMarked: CustomEvent<Feature[]>;
45
- response: CustomEvent<{
46
- url: string;
47
- featureCollection: FeatureCollection;
48
- }>;
49
- reverseToggle: CustomEvent<boolean>;
50
- queryChange: CustomEvent<string>;
40
+ select: CustomEvent<any>;
41
+ pick: CustomEvent<any>;
42
+ optionsVisibilityChange: CustomEvent<any>;
43
+ featuresListed: CustomEvent<any>;
44
+ featuresMarked: CustomEvent<any>;
45
+ reverseToggle: CustomEvent<any>;
46
+ queryChange: CustomEvent<any>;
47
+ response: CustomEvent<any>;
51
48
  } & {
52
49
  [evt: string]: CustomEvent<any>;
53
50
  };
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # MapTiler Geocoding control for MapLibre GL JS and Leaflet
1
+ # MapTiler Geocoding control for MapTiler SDK, MapLibre GL JS and Leaflet
2
2
 
3
- A geocoding control for [Maplibre GL JS](https://github.com/maplibre/maplibre-gl-js) and [Leaflet](https://github.com/maplibre/maplibre-gl-js) utilizes [MapTiler Cloud Geocoding API](https://www.maptiler.com/cloud/geocoding/). With this control, users of your application can find any place on Earth (States, Cities, Streets, ...) down to the address level, restrict the search area to a specific country, highlight searched results on the map, autocomplete words while typing, and much more.
3
+ A geocoding control for [MapTiler SDK](https://github.com/maptiler/maptiler-sdk-js), [MapLibre GL JS](https://github.com/maplibre/maplibre-gl-js) and [Leaflet](https://leafletjs.com) utilizes [MapTiler Cloud Geocoding API](https://www.maptiler.com/cloud/geocoding/). With this control, users of your application can find any place on Earth (States, Cities, Streets, ...) down to the address level, restrict the search area to a specific country, highlight searched results on the map, autocomplete words while typing, and much more.
4
4
 
5
5
  The component can be used as an ES module or UMD module.
6
6
 
@@ -8,7 +8,30 @@ Geocoding control is also provided as [React component](#react-component) and a
8
8
 
9
9
  ## Usage
10
10
 
11
- ### Example for Maplibre GL JS using module bundler
11
+ ### Example for MapTiler SDK using module bundler
12
+
13
+ ```
14
+ npm install --save @maptiler/geocoding-control @maptiler/sdk
15
+ ```
16
+
17
+ ```js
18
+ import * as maptilersdk from "@maptiler/sdk";
19
+ import { GeocodingControl } from "@maptiler/geocoding-control/maplibregl";
20
+ import "@maptiler/sdk/dist/maptiler-sdk.css";
21
+ import "@maptiler/geocoding-control/style.css";
22
+
23
+ maptilersdk.config.apiKey = "YOUR_MAPTILER_API_KEY_HERE";
24
+
25
+ const map = new maptilersdk.Map({
26
+ container: "map", // id of HTML container element
27
+ });
28
+
29
+ const gc = new GeocodingControl();
30
+
31
+ map.addControl(gc);
32
+ ```
33
+
34
+ ### Example for MapLibre GL JS using module bundler
12
35
 
13
36
  ```bash
14
37
  npm install --save @maptiler/geocoding-control maplibre-gl
@@ -34,7 +57,7 @@ const gc = new GeocodingControl({ apiKey, maplibregl });
34
57
  map.addControl(gc);
35
58
  ```
36
59
 
37
- ### Example for Leaflet using module bundler
60
+ ### Example for Leaflet using module bundler
38
61
 
39
62
  ```bash
40
63
  npm install --save @maptiler/geocoding-control leaflet
@@ -69,15 +92,15 @@ L.control.maptilerGeocoding({ apiKey }).addTo(map);
69
92
 
70
93
  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:
71
94
 
72
- - Maplibre GL JS: `sensible-browser file://$(pwd)/demo-maplibregl.html#key=YOUR_MAPTILER_API_KEY_HERE`
95
+ - MapLibre GL JS: `sensible-browser file://$(pwd)/demo-maplibregl.html#key=YOUR_MAPTILER_API_KEY_HERE`
73
96
  - Leaflet: `sensible-browser file://$(pwd)/demo-leaflet.html#key=YOUR_MAPTILER_API_KEY_HERE`
74
97
 
75
98
  ## API Documentation
76
99
 
77
100
  ### Options
78
101
 
79
- - `apiKey`<sup>\*</sup>: `string` - Maptiler API key
80
- - `maplibregl`: `MapLibreGL` - A Maplibre GL instance to use when creating [Markers](https://maplibre.org/maplibre-gl-js-docs/api/markers/#marker). Required if `options.marker` is `true`. Used only with Maplibre GL library.
102
+ - `apiKey`<sup>\*</sup>: `string` - Maptiler API key. Not needed if used with MapTiler SDK.
103
+ - `maplibregl`: `MapLibreGL` - A MapLibre GL instance to use when creating [Markers](https://maplibre.org/maplibre-gl-js-docs/api/markers/#marker). Used if `options.marker` is `true` with MapLibre GL library. If not provided it will be autodetected. Not needed if used with MapTiler SDK.
81
104
  - `debounceSearch`: `number` - Sets the amount of time, in milliseconds, to wait before querying the server when a user types into the Geocoder input box. This parameter may be useful for reducing the total number of API calls made for a single query. Default `200`.
82
105
  - `proximity`: `[number, number]` - A proximity argument: this is a geographical point given as an object with latitude and longitude properties. Search results closer to this point will be given higher priority.
83
106
  - `placeholder`: `string` - Override the default placeholder attribute value. Default `"Search"`.
@@ -112,6 +135,7 @@ For examples without using bundler see `demo-maplibregl.html` or `demo-leaflet.h
112
135
  - `focus(): void` - focus the query input box
113
136
  - `blur(): void` - blur the query input box
114
137
  - `setReverseMode(value: boolean | "always"): void` - set reverse mode
138
+ - `setOptions(options: Partial<Options>): void` - change one or more options of existing control
115
139
 
116
140
  ### Events
117
141
 
@@ -123,8 +147,8 @@ Events are implemented using [EventTarget](https://developer.mozilla.org/en-US/d
123
147
  - `featuresListed` - Fired after features are retrieved from the server. Event value contains list of features or `undefined`.
124
148
  - `featuresMarked` - Fired after features are marked on the map. Event value contains list of features or `undefined`.
125
149
  - `response` - Fired after HTTP response of the geocoding server. Event value contains object with requested `url` and responded `featureCollection`.
126
- - `reversetoggle` - Fired if reverse geocoding button is toggled. Event value is `true` if reverse geocoding mode is active, otherwise `false`.
127
- - `querychange` - Fired if query was changed. Event value is the query string.
150
+ - `reverseToggle` - Fired if reverse geocoding button is toggled. Event value is `true` if reverse geocoding mode is active, otherwise `false`.
151
+ - `queryChange` - Fired if query was changed. Event value is the query string.
128
152
 
129
153
  Example:
130
154
 
@@ -175,7 +199,10 @@ export function App() {
175
199
  <div>
176
200
  <GeocodingControl apiKey={apiKey} mapController={mapController} />
177
201
 
178
- <div ref={mapContainerRef} style={{ width: "800px", height: "600px", marginTop: "8px" }} />
202
+ <div
203
+ ref={mapContainerRef}
204
+ style={{ width: "800px", height: "600px", marginTop: "8px" }}
205
+ />
179
206
  </div>
180
207
  );
181
208
  }
@@ -204,14 +231,13 @@ Component API matches API described above where options and events are exposed a
204
231
  let container: HTMLElement;
205
232
 
206
233
  onMount(() => {
207
-
208
234
  const map = new maplibregl.Map({
209
235
  style: "https://api.maptiler.com/maps/streets/style.json?key=" + apiKey,
210
236
  container,
211
237
  });
212
238
 
213
239
  mapController = createMaplibreglMapController(map, maplibregl);
214
- }
240
+ });
215
241
  </script>
216
242
 
217
243
  <div class="map" bind:this={container} />