@maptiler/geocoding-control 0.0.78 → 0.0.81

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.
Files changed (48) hide show
  1. package/ClearIcon.svelte.d.ts +23 -0
  2. package/GeocodingControl.svelte +685 -0
  3. package/GeocodingControl.svelte.d.ts +66 -0
  4. package/LoadingIcon.svelte.d.ts +23 -0
  5. package/{src/lib/MarkerIcon.svelte → MarkerIcon.svelte} +1 -2
  6. package/MarkerIcon.svelte.d.ts +16 -0
  7. package/ReverseGeocodingIcon.svelte.d.ts +23 -0
  8. package/SearchIcon.svelte.d.ts +23 -0
  9. package/leaflet-controller.js +1 -0
  10. package/leaflet-controller.js.map +1 -0
  11. package/leaflet-controller.umd.js +1 -0
  12. package/leaflet-controller.umd.js.map +1 -0
  13. package/leaflet.js +3998 -4021
  14. package/leaflet.js.map +1 -0
  15. package/leaflet.umd.js +6 -5
  16. package/leaflet.umd.js.map +1 -0
  17. package/maplibregl-controller.js +1 -0
  18. package/maplibregl-controller.js.map +1 -0
  19. package/maplibregl-controller.umd.js +1 -0
  20. package/maplibregl-controller.umd.js.map +1 -0
  21. package/maplibregl.js +4089 -4112
  22. package/maplibregl.js.map +1 -0
  23. package/maplibregl.umd.js +6 -5
  24. package/maplibregl.umd.js.map +1 -0
  25. package/package.json +23 -23
  26. package/react.js +571 -649
  27. package/react.js.map +1 -0
  28. package/react.umd.js +2 -1
  29. package/react.umd.js.map +1 -0
  30. package/style.css +1 -1
  31. package/src/AppLeaflet.svelte +0 -55
  32. package/src/AppMaplibregl.svelte +0 -45
  33. package/src/lib/GeocodingControl.svelte +0 -839
  34. package/src/lib/LeafletGeocodingControl.ts +0 -154
  35. package/src/lib/MaplibreglGeocodingControl.ts +0 -160
  36. package/src/lib/ReactGeocodingControl.ts +0 -158
  37. package/src/lib/leafletMapController.ts +0 -305
  38. package/src/lib/maplibreglMapController.ts +0 -366
  39. package/src/lib/mask.ts +0 -70
  40. package/src/lib/types.ts +0 -235
  41. package/src/main-copy.ts +0 -59
  42. package/src/main.ts +0 -65
  43. package/src/vite-env.d.ts +0 -2
  44. /package/{src/lib/ClearIcon.svelte → ClearIcon.svelte} +0 -0
  45. /package/{src/lib/LoadingIcon.svelte → LoadingIcon.svelte} +0 -0
  46. /package/{src/lib/ReverseGeocodingIcon.svelte → ReverseGeocodingIcon.svelte} +0 -0
  47. /package/{src/lib/SearchIcon.svelte → SearchIcon.svelte} +0 -0
  48. /package/{maplibre.d.ts → maplibregl.d.ts} +0 -0
package/src/lib/mask.ts DELETED
@@ -1,70 +0,0 @@
1
- import type {
2
- Polygon,
3
- MultiPolygon,
4
- Feature as TurfFeature,
5
- Position,
6
- } from "@turf/helpers";
7
- import difference from "@turf/difference";
8
- import buffer from "@turf/buffer";
9
- import type { GeoJSON } from "geojson";
10
-
11
- // see https://maplibre.org/maplibre-gl-js-docs/example/line-across-180th-meridian/
12
- function fixRing(ring: Position[]) {
13
- let prev: Position | undefined = undefined;
14
-
15
- for (const c of ring) {
16
- if (prev && c[0] - prev[0] >= 180) {
17
- c[0] -= 360;
18
- } else if (prev && c[0] - prev[0] < -180) {
19
- c[0] += 360;
20
- }
21
-
22
- prev = c;
23
- }
24
- }
25
-
26
- export function setMask(
27
- picked: TurfFeature<Polygon | MultiPolygon>,
28
- setData: (data: GeoJSON) => void
29
- ) {
30
- const diff = difference(
31
- {
32
- type: "Polygon",
33
- coordinates: [
34
- [
35
- [180, 90],
36
- [-180, 90],
37
- [-180, -90],
38
- [180, -90],
39
- [180, 90],
40
- ],
41
- ],
42
- },
43
- picked
44
- );
45
-
46
- if (!diff) {
47
- return;
48
- }
49
-
50
- diff.properties = { isMask: "y" };
51
-
52
- const fixed = buffer(picked, 0);
53
-
54
- if (fixed.geometry.type === "Polygon") {
55
- for (const ring of fixed.geometry.coordinates) {
56
- fixRing(ring);
57
- }
58
- } else {
59
- for (const poly of fixed.geometry.coordinates) {
60
- for (const ring of poly) {
61
- fixRing(ring);
62
- }
63
- }
64
- }
65
-
66
- setData({
67
- type: "FeatureCollection",
68
- features: [fixed, diff],
69
- });
70
- }
package/src/lib/types.ts DELETED
@@ -1,235 +0,0 @@
1
- import type { Feature as FeatureType } from "geojson";
2
-
3
- export type Feature = FeatureType & {
4
- id: string;
5
- text: string;
6
- place_name: string;
7
- place_type: string[];
8
- center: [number, number];
9
- bbox: [number, number, number, number];
10
- address?: string;
11
- matching_text?: string;
12
- };
13
-
14
- export type FeatureCollection = {
15
- type: "FeatureCollection";
16
- features: Feature[];
17
- };
18
-
19
- export type MapEvent =
20
- | {
21
- type: "proximityChange";
22
- proximity: [number, number] | undefined;
23
- }
24
- | { type: "mapClick"; coordinates: [number, number] }
25
- | { type: "markerClick"; id: string }
26
- | { type: "markerMouseEnter"; id: string }
27
- | { type: "markerMouseLeave"; id: string };
28
-
29
- export type MapController = {
30
- setEventHandler(handler: undefined | ((e: MapEvent) => void)): void;
31
-
32
- flyTo(center: [number, number], zoom: number): void;
33
-
34
- fitBounds(bbox: [number, number, number, number], padding: number): void;
35
-
36
- indicateReverse(reverse: boolean): void;
37
-
38
- setMarkers(
39
- features: Feature[] | undefined,
40
- picked: Feature | undefined
41
- ): void;
42
-
43
- setReverseMarker(coordinates?: [number, number]): void;
44
-
45
- setSelectedMarker(index: number): void;
46
- };
47
-
48
- export type Proximity = [number, number] | undefined;
49
-
50
- export type ControlOptions = {
51
- /**
52
- * Maptiler API key
53
- */
54
- apiKey: string;
55
-
56
- /**
57
- * Sets the amount of time, in milliseconds, to wait before querying the server when a user types into the Geocoder input box.
58
- * This parameter may be useful for reducing the total number of API calls made for a single query.
59
- *
60
- * @default 200
61
- */
62
- debounceSearch?: number;
63
-
64
- /**
65
- * A proximity argument: this is a geographical point given as an object with latitude and longitude properties.
66
- * Search results closer to this point will be given higher priority.
67
- */
68
- proximity?: [number, number];
69
-
70
- /**
71
- * Override the default placeholder attribute value.
72
- *
73
- * @default "Search"
74
- */
75
- placeholder?: string;
76
-
77
- /**
78
- * Override the default error message.
79
- *
80
- * @default "Searching failed"
81
- */
82
- errorMessage?: string;
83
-
84
- /**
85
- * Override the default message if no results are found.
86
- *
87
- * @default "No results found"
88
- */
89
- noResultsMessage?: string;
90
-
91
- /**
92
- * If true, the geocoder proximity will automatically update based on the map view.
93
- *
94
- * @default true
95
- */
96
- trackProximity?: boolean;
97
-
98
- /**
99
- * Minimum number of characters to enter before results are shown.
100
- *
101
- * @default 2
102
- */
103
- minLength?: number;
104
-
105
- /**
106
- * A bounding box argument: this is a bounding box given as an array in the format [minX, minY, maxX, maxY].
107
- * Search results will be limited to the bounding box.
108
- */
109
- bbox?: [number, number, number, number];
110
-
111
- /**
112
- * Maximum number of results to show.
113
- *
114
- * @default 5
115
- */
116
- limit?: number;
117
-
118
- /**
119
- * Specify the language to use for response text and query result weighting.
120
- * Options are IETF language tags comprised of a mandatory ISO 639-1 language code and optionally one or more IETF subtags for country or script.
121
- * More than one value can also be specified, separated by commas.
122
- * Defaults to the browser's language settings.
123
- */
124
- language?: string | string[];
125
-
126
- /**
127
- * If `false`, indicates that search will only occur on enter key press.
128
- * If `true`, indicates that the Geocoder will search on the input box being updated above the minLength option.
129
- *
130
- * @default false
131
- */
132
- showResultsWhileTyping?: boolean;
133
-
134
- /**
135
- * Set to `false` to disable fuzzy search.
136
- *
137
- * @default true
138
- */
139
- fuzzyMatch?: boolean;
140
-
141
- /**
142
- * On geocoded result what zoom level should the map animate to when a bbox isn't found in the response.
143
- * If a bbox is found the map will fit to the bbox.
144
- *
145
- * @default 16
146
- */
147
- zoom?: number;
148
-
149
- /**
150
- * If `true`, the geocoder control will collapse until hovered or in focus.
151
- *
152
- * @default false
153
- */
154
- collapsed?: boolean;
155
-
156
- // /**
157
- // * If `true`, the geocoder control will clear it's contents and blur when user presses the escape key.
158
- // *
159
- // * @default false
160
- // */
161
- // clearAndBlurOnEsc?: boolean;
162
-
163
- /**
164
- * If true, the geocoder control will clear its value when the input blurs.
165
- *
166
- * @default false
167
- */
168
- clearOnBlur?: boolean;
169
-
170
- /**
171
- * A function which accepts a Feature in the Carmen GeoJSON format to filter out results from the Geocoding API response before they are included in the suggestions list.
172
- * Return true to keep the item, false otherwise.
173
- */
174
- filter?: (feature: Feature) => boolean;
175
-
176
- /**
177
- * Class of the root element.
178
- */
179
- class?: string;
180
-
181
- /**
182
- * Set to `true` to enable reverse geocoding button with title. Set to `"always"` to reverse geocoding be always active.
183
- *
184
- * @default false
185
- */
186
- enableReverse?: boolean | "always";
187
-
188
- /**
189
- * Reverse toggle button title.
190
- *
191
- * @default "toggle reverse geocoding"
192
- */
193
- reverseButtonTitle?: string;
194
-
195
- /**
196
- * Clear button title.
197
- *
198
- * @default "clear"
199
- */
200
- clearButtonTitle?: string;
201
-
202
- /**
203
- * Set to `true` to show place type.
204
- *
205
- * @default false
206
- */
207
- showPlaceType?: boolean;
208
-
209
- /**
210
- * Set to `true` to show full feature geometry of the chosen result. Otherwise only marker will be shown.
211
- *
212
- * @default true
213
- */
214
- showFullGeometry?: boolean;
215
-
216
- /**
217
- * Limit search to specified country(ies).
218
- *
219
- * @default undefined use all countries
220
- */
221
- country?: string | string[];
222
-
223
- /**
224
- * Filter of feature types to return.
225
- *
226
- * @default undefined all available feature types are returned
227
- */
228
- types?: string[];
229
-
230
- // TODO - missing but useful from maplibre-gl-geocoder
231
- // popup // If true, a Popup will be added to the map when clicking on a marker using a default set of popup options. If the value is an object, the popup will be constructed using these options. If false, no popup will be added to the map. Requires that options.maplibregl also be set. (optional, default true)
232
- // render // A function that specifies how the results should be rendered in the dropdown menu. This function should accepts a single Carmen GeoJSON object as input and return a string. Any HTML in the returned string will be rendered.
233
- // popupRender // A function that specifies how the results should be rendered in the popup menu. This function should accept a single Carmen GeoJSON object as input and return a string. Any HTML in the returned string will be rendered.
234
- // getItemValue // A function that specifies how the selected result should be rendered in the search bar. This function should accept a single Carmen GeoJSON object as input and return a string. HTML tags in the output string will not be rendered. Defaults to (item) => item.place_name.
235
- };
package/src/main-copy.ts DELETED
@@ -1,59 +0,0 @@
1
- // import App from "./AppMaplibregl.svelte";
2
-
3
- import { createElement, useEffect, useRef, useState } from "react";
4
- import { createRoot } from "react-dom/client";
5
- import {
6
- ReactGeocodingControl,
7
- type Methods,
8
- } from "./lib/ReactGeocodingControl";
9
-
10
- const appElement = document.getElementById("app");
11
-
12
- if (!appElement) {
13
- throw new Error("element with id 'app' not found");
14
- }
15
-
16
- // const app = new App({
17
- // target: appElement,
18
- // });
19
-
20
- // export default app;
21
-
22
- const apiKey = import.meta.env.VITE_API_KEY;
23
-
24
- if (!apiKey) {
25
- const errMsg = "missing VITE_API_KEY environment variable";
26
-
27
- window.alert(errMsg);
28
-
29
- throw new Error(errMsg);
30
- }
31
-
32
- const root = createRoot(appElement);
33
-
34
- function App() {
35
- const ref = useRef<Methods>(null);
36
-
37
- const [collapsed, setCollapsed] = useState(false);
38
-
39
- useEffect(() => {
40
- setTimeout(() => {
41
- ref.current?.focus();
42
- });
43
-
44
- setTimeout(() => {
45
- setCollapsed(true);
46
- }, 5000);
47
- }, []);
48
-
49
- return createElement(ReactGeocodingControl, {
50
- ref,
51
- apiKey,
52
- collapsed,
53
- onSelect: (f) => {
54
- console.log("select", f);
55
- },
56
- });
57
- }
58
-
59
- root.render(createElement(App));
package/src/main.ts DELETED
@@ -1,65 +0,0 @@
1
- import App from "./AppMaplibregl.svelte";
2
-
3
- import {
4
- createElement,
5
- useEffect,
6
- useLayoutEffect,
7
- useRef,
8
- useState,
9
- } from "react";
10
- import { createRoot } from "react-dom/client";
11
- import {
12
- ReactGeocodingControl,
13
- type Methods,
14
- } from "./lib/ReactGeocodingControl";
15
-
16
- const appElement = document.getElementById("app");
17
-
18
- if (!appElement) {
19
- throw new Error("element with id 'app' not found");
20
- }
21
-
22
- const app = new App({
23
- target: appElement,
24
- });
25
-
26
- export default app;
27
-
28
- // const apiKey = import.meta.env.VITE_API_KEY;
29
-
30
- // if (!apiKey) {
31
- // const errMsg = "missing VITE_API_KEY environment variable";
32
-
33
- // window.alert(errMsg);
34
-
35
- // throw new Error(errMsg);
36
- // }
37
-
38
- // const root = createRoot(appElement);
39
-
40
- // function App() {
41
- // const ref = useRef<Methods>(null);
42
-
43
- // const [collapsed, setCollapsed] = useState(false);
44
-
45
- // useEffect(() => {
46
- // setTimeout(() => {
47
- // ref.current?.focus();
48
- // });
49
-
50
- // setTimeout(() => {
51
- // setCollapsed(true);
52
- // }, 5000);
53
- // }, []);
54
-
55
- // return createElement(ReactGeocodingControl, {
56
- // ref,
57
- // apiKey,
58
- // collapsed,
59
- // onSelect: (f) => {
60
- // console.log("select", f);
61
- // },
62
- // });
63
- // }
64
-
65
- // root.render(createElement(App));
package/src/vite-env.d.ts DELETED
@@ -1,2 +0,0 @@
1
- /// <reference types="svelte" />
2
- /// <reference types="vite/client" />
File without changes
File without changes