@maptiler/geocoding-control 0.0.95 → 0.0.96-alpha.2

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.
@@ -39,7 +39,7 @@ export let maxZoom = 18;
39
39
  export let apiUrl = "https://api.maptiler.com/geocoding";
40
40
  export let fetchParameters = {};
41
41
  export let iconsBaseUrl = "https://cdn.maptiler.com/maptiler-geocoding-control/v" +
42
- "0.0.95" +
42
+ "0.0.96-alpha.2" +
43
43
  "/icons/";
44
44
  export function focus() {
45
45
  input.focus();
@@ -42,7 +42,7 @@ export type MapLibreBaseControlOptions = Omit<ControlOptions, "apiKey"> & {
42
42
  export type Props<T> = T extends SvelteComponent<infer P, any, any> ? P : never;
43
43
  export declare abstract class MapLibreBasedGeocodingControl<T extends MapLibreBaseControlOptions> extends EventTarget implements IControl {
44
44
  #private;
45
- constructor(options: T);
45
+ constructor(options?: T);
46
46
  abstract getExtraProps(map: Map, div: HTMLElement): Partial<Props<GeocodingControlComponent>>;
47
47
  onAdd(map: Map): HTMLDivElement;
48
48
  abstract getMapLibreGl(): typeof maplibregl;
package/README.md CHANGED
@@ -95,12 +95,64 @@ For examples without using bundler see `demo-maplibregl.html` or `demo-leaflet.h
95
95
  - MapLibre GL JS: `sensible-browser file://$(pwd)/demo-maplibregl.html#key=YOUR_MAPTILER_API_KEY_HERE`
96
96
  - Leaflet: `sensible-browser file://$(pwd)/demo-leaflet.html#key=YOUR_MAPTILER_API_KEY_HERE`
97
97
 
98
+ ### Example for vanilla JS using UMD
99
+
100
+ ```html
101
+ <script src="https://cdn.maptiler.com/maptiler-geocoding-control/v${version}/vanilla.js"></script>
102
+
103
+ <link
104
+ href="https://cdn.maptiler.com/maptiler-geocoding-control/v${version}/style.css"
105
+ rel="stylesheet"
106
+ />
107
+
108
+ <div id="container"></div>
109
+
110
+ <script>
111
+ const control = new maptilerGeocoder.GeocodingControl({
112
+ apiKey: "YOUR_MAPTILER_API_KEY_HERE",
113
+ target: document.getElementById("container"),
114
+ });
115
+
116
+ control.addEventListener("pick", (evt) => {
117
+ console.log("Picked:", evt.detail);
118
+ });
119
+ </script>
120
+ ```
121
+
122
+ This example doesn't use the map. To use it, you can include and use particular map controller (see `createLeafletMapController` or `createMapLibreGlMapController`).
123
+
124
+ Note: replace `${version}` with the desired library version.
125
+
126
+ ## UMD global variables
127
+
128
+ If you import script from CDN using `<script src="https://cdn.maptiler.com/maptiler-geocoding-control/v${version}/${Script filename}"></script>` then it creates a global variable according to the following table:
129
+
130
+ | Script filename | UMD global variable name | Exports |
131
+ | ------------------------------ | --------------------------------------- | ------------------------------------------------------------------ |
132
+ | `leaflet.umd.js` | `leafletMaptilerGeocoder` | `class GeocodingControl`,`function createLeafletMapController` |
133
+ | `maplibregl.umd.js` | `maplibreglMaptilerGeocoder` | `class GeocodingControl`, `function createMapLibreGlMapController` |
134
+ | `maptilersdk.umd.js` | `maptilersdkMaptilerGeocoder` | `class GeocodingControl` |
135
+ | `react.umd.js` | `reactMaptilerGeocoder` | `class GeocodingControl` |
136
+ | `vanilla.umd.js` | `maptilerGeocoder` | `class GeocodingControl` |
137
+ | `leaflet-controller.umd.js` | `leafletMaptilerGeocodingController` | `function createLeafletMapController` |
138
+ | `maplibregl-controller.umd.js` | `maplibreglMaptilerGeocodingController` | `function createMapLibreGlMapController` |
139
+
140
+ The variable is an object with properties representing library-exported variables, for example `maplibreglMaptilerGeocoder.GeocodingControl`.
141
+
142
+ Notes:
143
+
144
+ - alternatively you can use different CDN, for example `https://www.unpkg.com/@maptiler/geocoding-control@${version}/maplibregl.umd.js`
145
+ - replace `${version}` with the desired library version and `${Script filename}` with the script filename from the table above.
146
+
98
147
  ## API Documentation
99
148
 
100
149
  ### Options
101
150
 
102
151
  - `apiKey`<sup>\*</sup>: `string` - Maptiler API key. Not needed if used with MapTiler SDK.
103
152
  - `maplibregl`: `MapLibreGL` - A MapLibre GL JS 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 JS library. If not provided it will be autodetected. Not needed if used with MapTiler SDK.
153
+ - `apiUrl`: `string` - Geocoding API URL. Default MapTiler Geocoding API URL.
154
+ - `fetchParameters`: `RequestInit` - Extra fetch parameters. Default `undefined`.
155
+ - `iconsBaseUrl`: `string` - Base URL for POI icons. Default `"icons/"` for Svelte apps, otherwise <code>`https://cdn.maptiler.com/maptiler-geocoding-control/v${version}/icons/`</code>.
104
156
  - `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`.
105
157
  - `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.
106
158
  - `placeholder`: `string` - Override the default placeholder attribute value. Default `"Search"`.
@@ -110,7 +162,7 @@ For examples without using bundler see `demo-maplibregl.html` or `demo-leaflet.h
110
162
  - `minLength`: `number` - Minimum number of characters to enter for results to show. Default `2`.
111
163
  - `bbox`: `[number, number, number, number]` - A bounding box argument: this is a bounding box given as an array in the format [minX, minY, maxX, maxY]. Search results will be limited to the bounding box.
112
164
  - `language`: `string | string[]` - Specify the language(s) to use for response text and query result weighting. 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. More than one value can also be specified, separated by commas. Set to empty string or empty array for forcing no language preference. If this parameter is not provided at all the browser's language settings will be used.
113
- - `showResultsWhileTyping`: `boolean` - If `false`, indicates that search will only occur on enter key press. If `true`, indicates that the Geocoder will search on the input box being updated above the minLength option. Default `false`.
165
+ - `showResultsWhileTyping`: `boolean` - If `false`, indicates that search will only occur on enter key press. If `true`, indicates that the Geocoder will search on the input box being updated above the minLength option. Default `true`.
114
166
  - `marker`: `boolean | MarkerOptions` - If `true`, a [MapLibre GL JS Marker](https://maplibre.org/maplibre-gl-js-docs/api/markers/#marker) / [Leaflet Marker](https://leafletjs.com/reference.html#marker) will be added to the map at the location of the user-selected result using a default set of Marker options. If the value is an object, the marker will be constructed using these options. If `false`, no marker will be added to the map. Requires that `options.maplibregl` also be set. Default `true`.
115
167
  - `showResultMarkers`: `boolean | MarkerOptions` - If `true`, [MapLibre GL JS Marker](https://maplibre.org/maplibre-gl-js-docs/api/markers/#marker) / [Leaflet Marker](https://leafletjs.com/reference.html#marker) will be added to the map at the location the top results for the query. If the value is an object, the marker will be constructed using these options. If `false`, no marker will be added to the map. Requires that `options.maplibregl` also be set. Default `true`.
116
168
  - `zoom`: `number` - On geocoded result what zoom level should the map animate to when a bbox isn't found in the response. If a bbox is found the map will fit to the bbox. Default `16`.
@@ -121,6 +173,7 @@ For examples without using bundler see `demo-maplibregl.html` or `demo-leaflet.h
121
173
  - `class`: `string` - Class of the root element.
122
174
  - `enableReverse`: `boolean | "always""` - Set to `true` to enable reverse geocoding button with title. Set to `"always"` to reverse geocoding be always active. Default `false`.
123
175
  - `reverseButtonTitle`: `string` - Reverse toggle button title. Default `"toggle reverse geocoding"`.
176
+ - `reverseActive`: `boolean` - Set to `true` to programatically toggle reverse mode. Useful only if `enableReverse` is `true`.
124
177
  - `clearButtonTitle`: `string` - Clear button title. Default `"clear"`.
125
178
  - `showFullGeometry`: `boolean` - Set to `true` to show full feature geometry of the chosen result. Otherwise only marker will be shown. Default `true`.
126
179
  - `fullGeometryStyle`: `{ fill: Pick<FillLayerSpecification, "layout" | "paint" | "filter">; line: Pick<LineLayerSpecification, "layout" | "paint" | "filter">; } | (L.PathOptions | L.StyleFunction)` - style of the full feature geometry. See Mapplibre GL JS or Leaflet documentation.
@@ -128,16 +181,12 @@ For examples without using bundler see `demo-maplibregl.html` or `demo-leaflet.h
128
181
  - `limit`: `number` - Maximum number of results to show. Default `5`.
129
182
  - `country`: `string | string[]` - Limit search to specified country(ies). Default `undefined` (use all countries). Specify as [alpha-2 ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) lowercase code.
130
183
  - `types`: `string[]` - Filter of feature types to return. Default `undefined` (all available feature types are returned).
131
- - `apiUrl`: `string` - Geocoding API URL. Default MapTiler Geocoding API URL.
132
- - `fetchParameters`: `RequestInit` - Extra fetch parameters. Default `undefined`.
133
- - `iconsBaseUrl`: `string` - Base URL for POI icons. Default `"icons/"` for Svelte apps, otherwise <code>`https://cdn.maptiler.com/maptiler-geocoding-control/v${version}/icons/`</code>.
134
184
 
135
185
  ### Methods
136
186
 
137
187
  - `setQuery(value: string, submit = true): void` - set the query and optionally submit it
138
188
  - `focus(): void` - focus the query input box
139
189
  - `blur(): void` - blur the query input box
140
- - `setReverseMode(value: boolean | "always"): void` - set reverse mode
141
190
  - `setOptions(options: Partial<Options>): void` - change one or more options of existing control
142
191
 
143
192
  ### Events
package/leaflet.d.ts CHANGED
@@ -37,7 +37,6 @@ export declare class GeocodingControl extends L.Control {
37
37
  onAdd(map: L.Map): HTMLDivElement;
38
38
  setOptions(options: LeafletControlOptions): void;
39
39
  setQuery(value: string, submit?: boolean): void;
40
- setReverseMode(value: boolean): void;
41
40
  focus(): void;
42
41
  blur(): void;
43
42
  onRemove(): void;