@maptiler/geocoding-control 0.0.94 → 0.0.96-alpha.1

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.
@@ -36,14 +36,11 @@ export let trackProximity = true;
36
36
  export let types = undefined;
37
37
  export let zoom = 16;
38
38
  export let maxZoom = 18;
39
- export let apiUrl = import.meta.env.VITE_API_URL;
39
+ export let apiUrl = "https://api.maptiler.com/geocoding";
40
40
  export let fetchParameters = {};
41
- export let iconsBaseUrl = import.meta.env.VITE_FLAVOUR
42
- ? "https://cdn.maptiler.com/maptiler-geocoding-control/v" +
43
- "0.0.92" +
44
- // TODO sync it import.meta.env.VITE_LIB_VERSION +
45
- "/icons/"
46
- : "icons/";
41
+ export let iconsBaseUrl = "https://cdn.maptiler.com/maptiler-geocoding-control/v" +
42
+ "0.0.96-alpha.1" +
43
+ "/icons/";
47
44
  export function focus() {
48
45
  input.focus();
49
46
  }
@@ -1,6 +1,6 @@
1
1
  import type * as maplibregl from "maplibre-gl";
2
2
  import type { FillLayerSpecification, FitBoundsOptions, FlyToOptions, IControl, LineLayerSpecification, Map, MarkerOptions } from "maplibre-gl";
3
- import type { SvelteComponentTyped } from "svelte";
3
+ import type { SvelteComponent } from "svelte";
4
4
  import GeocodingControlComponent from "./GeocodingControl.svelte";
5
5
  import type { ControlOptions } from "./types";
6
6
  export { createMapLibreGlMapController } from "./maplibregl-controller";
@@ -39,10 +39,10 @@ export type MapLibreBaseControlOptions = Omit<ControlOptions, "apiKey"> & {
39
39
  line: Pick<LineLayerSpecification, "layout" | "paint" | "filter">;
40
40
  };
41
41
  };
42
- export type Props<T> = T extends SvelteComponentTyped<infer P, any, any> ? P : never;
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
@@ -101,6 +101,9 @@ For examples without using bundler see `demo-maplibregl.html` or `demo-leaflet.h
101
101
 
102
102
  - `apiKey`<sup>\*</sup>: `string` - Maptiler API key. Not needed if used with MapTiler SDK.
103
103
  - `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.
104
+ - `apiUrl`: `string` - Geocoding API URL. Default MapTiler Geocoding API URL.
105
+ - `fetchParameters`: `RequestInit` - Extra fetch parameters. Default `undefined`.
106
+ - `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
107
  - `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
108
  - `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
109
  - `placeholder`: `string` - Override the default placeholder attribute value. Default `"Search"`.
@@ -110,7 +113,7 @@ For examples without using bundler see `demo-maplibregl.html` or `demo-leaflet.h
110
113
  - `minLength`: `number` - Minimum number of characters to enter for results to show. Default `2`.
111
114
  - `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
115
  - `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`.
116
+ - `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
117
  - `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
118
  - `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
119
  - `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 +124,7 @@ For examples without using bundler see `demo-maplibregl.html` or `demo-leaflet.h
121
124
  - `class`: `string` - Class of the root element.
122
125
  - `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
126
  - `reverseButtonTitle`: `string` - Reverse toggle button title. Default `"toggle reverse geocoding"`.
127
+ - `reverseActive`: `boolean` - Set to `true` to programatically toggle reverse mode. Useful only if `enableReverse` is `true`.
124
128
  - `clearButtonTitle`: `string` - Clear button title. Default `"clear"`.
125
129
  - `showFullGeometry`: `boolean` - Set to `true` to show full feature geometry of the chosen result. Otherwise only marker will be shown. Default `true`.
126
130
  - `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 +132,12 @@ For examples without using bundler see `demo-maplibregl.html` or `demo-leaflet.h
128
132
  - `limit`: `number` - Maximum number of results to show. Default `5`.
129
133
  - `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
134
  - `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
135
 
135
136
  ### Methods
136
137
 
137
138
  - `setQuery(value: string, submit = true): void` - set the query and optionally submit it
138
139
  - `focus(): void` - focus the query input box
139
140
  - `blur(): void` - blur the query input box
140
- - `setReverseMode(value: boolean | "always"): void` - set reverse mode
141
141
  - `setOptions(options: Partial<Options>): void` - change one or more options of existing control
142
142
 
143
143
  ### Events
@@ -163,8 +163,6 @@ geocodingControl.addEventListener("optionsVisibilityChange", (e) => {
163
163
 
164
164
  ## POI icons and bundlers
165
165
 
166
- (Skip if the component is used within Svelte webapp.)
167
-
168
166
  POI icons are served from CDN per default.
169
167
  If there is an requirement to serve them from a different location and the control is used in the application which is build with Web Application bundler (like Webpack, Vite) then it is necessary to do some extra cponfiguration.
170
168
  Icons are bundled in the library and you can find them in `node_modules/@maptiler/geocoding-control/icons`.
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;