@maptiler/geocoding-control 0.0.83 → 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.
- package/DispatcherType.d.ts +14 -0
- package/GeocodingControl.svelte +5 -3
- package/GeocodingControl.svelte.d.ts +9 -12
- package/README.md +32 -5
- package/leaflet-controller.js +450 -450
- package/leaflet-controller.js.map +1 -1
- package/leaflet-controller.umd.js +5 -5
- package/leaflet-controller.umd.js.map +1 -1
- package/leaflet.d.ts +2 -2
- package/leaflet.js +407 -407
- package/leaflet.js.map +1 -1
- package/leaflet.umd.js +5 -5
- package/leaflet.umd.js.map +1 -1
- package/maplibregl-controller.d.ts +2 -2
- package/maplibregl-controller.js +450 -450
- package/maplibregl-controller.js.map +1 -1
- package/maplibregl-controller.umd.js +5 -5
- package/maplibregl-controller.umd.js.map +1 -1
- package/maplibregl.d.ts +2 -2
- package/maplibregl.js +417 -417
- package/maplibregl.js.map +1 -1
- package/maplibregl.umd.js +5 -5
- package/maplibregl.umd.js.map +1 -1
- package/mask.d.ts +1 -1
- package/package.json +7 -6
- package/react.d.ts +11 -18
- package/react.js +196 -196
- package/react.js.map +1 -1
- package/react.umd.js +1 -1
- package/react.umd.js.map +1 -1
- package/style.css +1 -1
|
@@ -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
|
+
};
|
package/GeocodingControl.svelte
CHANGED
|
@@ -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
|
|
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 &&
|
|
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();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { Feature,
|
|
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<
|
|
41
|
-
pick: CustomEvent<
|
|
42
|
-
optionsVisibilityChange: CustomEvent<
|
|
43
|
-
featuresListed: CustomEvent<
|
|
44
|
-
featuresMarked: CustomEvent<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
@@ -8,6 +8,29 @@ Geocoding control is also provided as [React component](#react-component) and a
|
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
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
|
+
|
|
11
34
|
### Example for MapLibre GL JS using module bundler
|
|
12
35
|
|
|
13
36
|
```bash
|
|
@@ -34,7 +57,7 @@ const gc = new GeocodingControl({ apiKey, maplibregl });
|
|
|
34
57
|
map.addControl(gc);
|
|
35
58
|
```
|
|
36
59
|
|
|
37
|
-
### Example for Leaflet
|
|
60
|
+
### Example for Leaflet using module bundler
|
|
38
61
|
|
|
39
62
|
```bash
|
|
40
63
|
npm install --save @maptiler/geocoding-control leaflet
|
|
@@ -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
|
-
- `
|
|
127
|
-
- `
|
|
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
|
|
202
|
+
<div
|
|
203
|
+
ref={mapContainerRef}
|
|
204
|
+
style={{ width: "800px", height: "600px", marginTop: "8px" }}
|
|
205
|
+
/>
|
|
179
206
|
</div>
|
|
180
207
|
);
|
|
181
208
|
}
|
|
@@ -210,7 +237,7 @@ Component API matches API described above where options and events are exposed a
|
|
|
210
237
|
});
|
|
211
238
|
|
|
212
239
|
mapController = createMaplibreglMapController(map, maplibregl);
|
|
213
|
-
}
|
|
240
|
+
});
|
|
214
241
|
</script>
|
|
215
242
|
|
|
216
243
|
<div class="map" bind:this={container} />
|