@maptiler/geocoding-control 3.0.0-rc.1 → 3.0.0-rc.3
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/README.md +115 -51
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +17 -17
- package/dist/index.umd.js.map +1 -1
- package/dist/leaflet.public.js +47 -69
- package/dist/leaflet.public.js.map +1 -1
- package/dist/leaflet.public.umd.js +14 -14
- package/dist/leaflet.public.umd.js.map +1 -1
- package/dist/maplibregl.js +52 -74
- package/dist/maplibregl.js.map +1 -1
- package/dist/maplibregl.umd.js +14 -14
- package/dist/maplibregl.umd.js.map +1 -1
- package/dist/maptilersdk.js +49 -71
- package/dist/maptilersdk.js.map +1 -1
- package/dist/maptilersdk.umd.js +14 -14
- package/dist/maptilersdk.umd.js.map +1 -1
- package/dist/openlayers.public.js +1280 -0
- package/dist/openlayers.public.js.map +1 -0
- package/dist/openlayers.public.umd.js +276 -0
- package/dist/openlayers.public.umd.js.map +1 -0
- package/dist/src/controls/base-control.d.ts +44 -0
- package/dist/src/controls/leaflet-control.d.ts +4 -35
- package/dist/src/controls/maplibregl-control.d.ts +14 -35
- package/dist/src/controls/maptilersdk-control.d.ts +2 -1
- package/dist/src/controls/openlayers-control.d.ts +35 -0
- package/dist/src/controls/openlayers-events.d.ts +43 -0
- package/dist/src/controls/openlayers-options.d.ts +83 -0
- package/dist/src/geocoder/geocoder-options.d.ts +17 -1
- package/dist/src/geocoder/geocoder.d.ts +2 -1
- package/dist/src/openlayers.public.d.ts +7 -0
- package/dist/src/types.d.ts +1 -0
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -1,47 +1,42 @@
|
|
|
1
|
-
<
|
|
2
|
-
<a href="https://www.maptiler.com/cloud/geocoding/">official page →</a><br>
|
|
3
|
-
<img src="images/maptiler-logo.svg" width="350px">
|
|
4
|
-
</p>
|
|
5
|
-
|
|
6
|
-
<p align="center" style="color: #AAA">
|
|
7
|
-
The Javascript & TypeScript Map Control component for <a href="https://www.maptiler.com/cloud/geocoding">MapTiler Geocoding</a> service! Easy to be integrated into any JavaScript mapping application.
|
|
8
|
-
</p>
|
|
9
|
-
|
|
10
|
-
<p align="center">
|
|
11
|
-
<img src="images/JS-logo.svg" width="20px">
|
|
12
|
-
<img src="images/TS-logo.svg" width="20px">
|
|
13
|
-
<img src="images/react-logo.svg" width="20px">
|
|
14
|
-
<img src="images/svelte-logo.svg" width="20px">
|
|
15
|
-
<img src="https://img.shields.io/npm/v/@maptiler/geocoding-control"></img>
|
|
16
|
-
<img src="https://img.shields.io/twitter/follow/maptiler?style=social"></img>
|
|
17
|
-
</p>
|
|
1
|
+
<img src="https://raw.githubusercontent.com/maptiler/maptiler-sdk-kotlin/main/Examples/maptiler-logo.png" alt="Company Logo" height="32"/>
|
|
18
2
|
|
|
19
3
|
# MapTiler Search and Geocoding control for MapTiler SDK, MapLibre GL JS, Leaflet and OpenLayers
|
|
20
4
|
|
|
21
|
-
|
|
5
|
+
The Javascript & TypeScript Map Control component for <a href="https://www.maptiler.com/cloud/geocoding">MapTiler Geocoding</a> service! Easy to be integrated into any JavaScript mapping application.
|
|
22
6
|
|
|
23
7
|
The _MapTiler Geocoding control_ implements a powerful search box in your maps or online forms, enabling your application users to find any place on Earth down to individual addresses. Use the search box control with [MapTiler SDK JS](https://docs.maptiler.com/sdk-js/) (or other map libraries like [Leaflet](https://docs.maptiler.com/leaflet/), [MapLibre GL JS](https://github.com/maplibre/maplibre-gl-js), [OpenLayers](https://docs.maptiler.com/openlayers/)).
|
|
24
8
|
|
|
25
|
-
> ⚠️ _MapTiler Geocoding control_ v3 support for _OpenLayers_ is to be added soon. In the meantime, please use _MapTiler Geocoding control_ v2 with
|
|
9
|
+
> ⚠️ _MapTiler Geocoding control_ v3 support for _Leaflet_ (v1 and v2) and _OpenLayers_ is to be added soon. In the meantime, please use _MapTiler Geocoding control_ v2 with these map libraries.
|
|
26
10
|
|
|
27
|
-
|
|
11
|
+
[](https://www.npmjs.com/package/@maptiler/geocoding-control)
|
|
12
|
+

|
|
28
13
|
|
|
29
|
-
|
|
14
|
+
---
|
|
30
15
|
|
|
31
|
-
|
|
16
|
+
📖 [Documentation](https://docs.maptiler.com/sdk-js/modules/geocoding/) 📦 [NPM Package](https://www.npmjs.com/package/@maptiler/geocoding-control) 🌐 [Website](https://www.maptiler.com/search/) 🔑 [Get API Key](https://cloud.maptiler.com/account/keys/)
|
|
32
17
|
|
|
33
|
-
|
|
34
|
-
- Find and identify objects or place names using a coordinate pair or a single mouse click (reverse geocoding)
|
|
35
|
-
- Restrict the search area to a specific country, bounding box, or proximity
|
|
36
|
-
- Highlight searched results on the map (marker or full geometry)
|
|
37
|
-
- Autocomplete words while typing
|
|
38
|
-
- and much more. Check out the [Geocoding Control API reference](https://docs.maptiler.com/sdk-js/modules/geocoding/api/api-reference/#options) to see all the options.
|
|
18
|
+
---
|
|
39
19
|
|
|
40
|
-
|
|
20
|
+
<br>
|
|
41
21
|
|
|
42
|
-
|
|
22
|
+
<details> <summary><b>Table of Contents</b></summary>
|
|
23
|
+
<ul>
|
|
24
|
+
<li><a href="#-installation">Installation</a></li>
|
|
25
|
+
<li><a href="#-basic-usage">Basic Usage</a></li>
|
|
26
|
+
<li><a href="#-related-examples">Examples</a></li>
|
|
27
|
+
<li><a href="#-api-reference">API Reference</a></li>
|
|
28
|
+
<li><a href="#migration-guide">Migration Guide</a></li>
|
|
29
|
+
<li><a href="#-support">Support</a></li>
|
|
30
|
+
<li><a href="#-contributing">Contributing</a></li>
|
|
31
|
+
<li><a href="#-license">License</a></li>
|
|
32
|
+
<li><a href="#-acknowledgements">Acknowledgements</a></li>
|
|
33
|
+
</ul>
|
|
34
|
+
</details>
|
|
43
35
|
|
|
44
|
-
|
|
36
|
+
<p align="center"> <img src="https://www.metalocator.com/wp-content/uploads/2022/07/maptiler-cloud-jp.jpg" alt="Demo Screenshot" width="80%"/> <br /> <a href="#">See live interactive demo</a> </p>
|
|
37
|
+
<br>
|
|
38
|
+
|
|
39
|
+
## 📦 Installation
|
|
45
40
|
|
|
46
41
|
Install the Geocoding control unsing `npm`, together with your map library (MapTiler SDK as an example):
|
|
47
42
|
|
|
@@ -49,7 +44,9 @@ Install the Geocoding control unsing `npm`, together with your map library (MapT
|
|
|
49
44
|
npm install --save @maptiler/geocoding-control @maptiler/sdk
|
|
50
45
|
```
|
|
51
46
|
|
|
52
|
-
|
|
47
|
+
<br>
|
|
48
|
+
|
|
49
|
+
## 🚀 Basic Usage
|
|
53
50
|
|
|
54
51
|
Use the component in your mapping application (MapTiler SDK as an example):
|
|
55
52
|
|
|
@@ -57,7 +54,6 @@ Use the component in your mapping application (MapTiler SDK as an example):
|
|
|
57
54
|
import * as maptilersdk from "@maptiler/sdk";
|
|
58
55
|
import { GeocodingControl } from "@maptiler/geocoding-control/maptilersdk";
|
|
59
56
|
import "@maptiler/sdk/dist/maptiler-sdk.css";
|
|
60
|
-
import "@maptiler/geocoding-control/style.css";
|
|
61
57
|
|
|
62
58
|
maptilersdk.config.apiKey = "YOUR_MAPTILER_API_KEY_HERE";
|
|
63
59
|
|
|
@@ -70,30 +66,60 @@ const gc = new GeocodingControl();
|
|
|
70
66
|
map.addControl(gc);
|
|
71
67
|
```
|
|
72
68
|
|
|
73
|
-
|
|
69
|
+
<br>
|
|
70
|
+
|
|
71
|
+
## 💡 Related Examples
|
|
72
|
+
|
|
73
|
+
- [With MapTiler SDK](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/sdk-js/)
|
|
74
|
+
- [With MapLibre GL](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/maplibre-gl-js/)
|
|
75
|
+
- [With Leaflet](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/leaflet/)
|
|
76
|
+
- [With OpenLayers](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/openlayers/)
|
|
77
|
+
- [As a React component](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/react/)
|
|
78
|
+
- [As Svelte component](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/svelte/)
|
|
79
|
+
- [As vanilla JavaScript module](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/vanilla-js/)
|
|
80
|
+
|
|
81
|
+
Check out the full list of [MapTiler geocoding examples](https://docs.maptiler.com/sdk-js/examples/?q=geocoding)
|
|
82
|
+
|
|
83
|
+
<br>
|
|
84
|
+
|
|
85
|
+
## 📘 API Reference
|
|
86
|
+
|
|
87
|
+
For detailed guides, API reference, and advanced examples, visit our comprehensive documentation:
|
|
88
|
+
|
|
89
|
+
[API documentation](https://docs.maptiler.com/sdk-js/modules/geocoding/api/api-reference/)
|
|
90
|
+
|
|
91
|
+
[Geocoding service API documentation](https://docs.maptiler.com/cloud/api/geocoding/)
|
|
92
|
+
|
|
93
|
+
[UMD global variables](https://docs.maptiler.com/sdk-js/modules/geocoding/#umd-global-variables)
|
|
94
|
+
|
|
95
|
+
<br>
|
|
74
96
|
|
|
75
|
-
##
|
|
97
|
+
## 💬 Support
|
|
76
98
|
|
|
77
|
-
- [
|
|
78
|
-
- [
|
|
79
|
-
- [
|
|
80
|
-
- [With Leaflet](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/leaflet/) _(to be updated for v3)_
|
|
81
|
-
- [With OpenLayers](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/openlayers/) _(to be updated for v3)_
|
|
82
|
-
- [As a React component](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/react/) _(to be updated for v3)_
|
|
83
|
-
- [As Svelte component](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/svelte/) _(to be updated for v3)_
|
|
84
|
-
- [As vanilla JavaScript module](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/vanilla-js/) _(to be updated for v3)_
|
|
99
|
+
- 📚 [Documentation](https://docs.maptiler.com/sdk-js/modules/geocoding/) - Comprehensive guides and API reference
|
|
100
|
+
- ✉️ [Contact us](https://maptiler.com/contact) - Get in touch or submit a request
|
|
101
|
+
- 🐦 [Twitter/X](https://twitter.com/maptiler) - Follow us for updates
|
|
85
102
|
|
|
86
|
-
|
|
103
|
+
<br>
|
|
87
104
|
|
|
88
|
-
|
|
105
|
+
---
|
|
89
106
|
|
|
90
|
-
|
|
91
|
-
- [The complete Geocoding control reference](https://docs.maptiler.com/sdk-js/modules/geocoding/api/api-reference/) _(to be updated for v3)_
|
|
92
|
-
- [UMD global variables](https://docs.maptiler.com/sdk-js/modules/geocoding/#umd-global-variables) _(to be updated for v3)_
|
|
107
|
+
<br>
|
|
93
108
|
|
|
94
|
-
##
|
|
109
|
+
## 🤝 Contributing
|
|
95
110
|
|
|
96
|
-
|
|
111
|
+
We love contributions from the community! Whether it's bug reports, feature requests, or pull requests, all contributions are welcome:
|
|
112
|
+
|
|
113
|
+
- Fork the repository and create your branch from `main`
|
|
114
|
+
- If you've added code, add tests that cover your changes
|
|
115
|
+
- Ensure your code follows our style guidelines
|
|
116
|
+
- Give your pull request a clear, descriptive summary
|
|
117
|
+
- Open a Pull Request with a comprehensive description
|
|
118
|
+
- Read the [CONTRIBUTING](./CONTRIBUTING.md) file
|
|
119
|
+
|
|
120
|
+
### Development
|
|
121
|
+
|
|
122
|
+
#### Building
|
|
97
123
|
|
|
98
124
|
```bash
|
|
99
125
|
npm install && npm run build
|
|
@@ -101,7 +127,7 @@ npm install && npm run build
|
|
|
101
127
|
|
|
102
128
|
You will find compilation result in the `dist` directory.
|
|
103
129
|
|
|
104
|
-
|
|
130
|
+
#### Running in dev mode
|
|
105
131
|
|
|
106
132
|
```bash
|
|
107
133
|
npm install && VITE_API_KEY=YOUR_MAPTILER_API_KEY_HERE npm run dev
|
|
@@ -112,3 +138,41 @@ Alternatively, you can provide your API key via `key` URL param.
|
|
|
112
138
|
### POI icons and bundlers
|
|
113
139
|
|
|
114
140
|
POI icons are served from CDN per default. If there is an requirement to serve them from a different location and the control is used in the application which is built with Web Application bundler (like Webpack or Vite) then it is necessary to do some extra configuration. Icons are bundled in the library and you can find them in `node_modules/@maptiler/geocoding-control/icons`. Configure your bundler and/or provide `iconsBaseUrl` option for the icons to be properly resolved. You can also copy icons from that directory to your `public` directory.
|
|
141
|
+
|
|
142
|
+
<br>
|
|
143
|
+
|
|
144
|
+
## 📄 License
|
|
145
|
+
|
|
146
|
+
This project is licensed under the BSD 3-Clause License – see the [LICENSE](./LICENSE) file for details.
|
|
147
|
+
|
|
148
|
+
<br>
|
|
149
|
+
|
|
150
|
+
## 🙏 Acknowledgements
|
|
151
|
+
|
|
152
|
+
The _Geocoding control_ uses the [MapTiler Geocoding API](https://www.maptiler.com/cloud/geocoding/). You can use the API directly from your web or backend applications or use the [API Client JS](https://docs.maptiler.com/client-js/) library.
|
|
153
|
+
|
|
154
|
+
With this control, users of mapping application can:
|
|
155
|
+
|
|
156
|
+
- Find any place on Earth (States, Cities, Streets, Addresses, POIs, ...) down to the address level
|
|
157
|
+
- Find and identify objects or place names using a coordinate pair or a single mouse click (reverse geocoding)
|
|
158
|
+
- Restrict the search area to a specific country, bounding box, or proximity
|
|
159
|
+
- Highlight searched results on the map (marker or full geometry)
|
|
160
|
+
- Autocomplete words while typing
|
|
161
|
+
- and much more. Check out the [Geocoding Control API reference](https://docs.maptiler.com/sdk-js/modules/geocoding/api/api-reference/#options) to see all the options.
|
|
162
|
+
|
|
163
|
+
The component can be used as an ES module or UMD module with or without bundler.
|
|
164
|
+
|
|
165
|
+
Geocoding control itself is provided as a [Web component](https://developer.mozilla.org/en-US/docs/Web/API/Web_components) which can be used with [React](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/react/), [Svelte](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/svelte/), and any other modern frontend library, or without any library at all.
|
|
166
|
+
|
|
167
|
+
<br>
|
|
168
|
+
|
|
169
|
+
<p align="center" style="margin-top:20px;margin-bottom:20px;"> <a href="https://cloud.maptiler.com/account/keys/" style="display:inline-block;padding:12px 32px;background:#F2F6FF;color:#000;font-weight:bold;border-radius:6px;text-decoration:none;"> Get Your API Key <sup style="background-color:#0000ff;color:#fff;padding:2px 6px;font-size:12px;border-radius:3px;">FREE</sup><br /> <span style="font-size:90%;font-weight:400;">Start building with 100,000 free map loads per month ・ No credit card required.</span> </a> </p>
|
|
170
|
+
|
|
171
|
+
<br>
|
|
172
|
+
|
|
173
|
+
<p align="center"> 💜 Made with love by the <a href="https://www.maptiler.com/">MapTiler</a> team <br />
|
|
174
|
+
<p align="center">
|
|
175
|
+
<a href="https://www.maptiler.com/search/">Website</a> •
|
|
176
|
+
<a href="https://docs.maptiler.com/sdk-js/modules/geocoding/">Documentation</a> •
|
|
177
|
+
<a href="https://github.com/maptiler/maptiler-geocoding-control">GitHub</a>
|
|
178
|
+
</p>
|
package/dist/index.js
CHANGED
|
@@ -409,7 +409,7 @@ let a = class extends L {
|
|
|
409
409
|
willUpdate(e) {
|
|
410
410
|
e.has("error") && this.error && console.error("[MapTilerGeocodingControl] Error:", this.error), e.has("enableReverse") && (this.reverseActive = this.enableReverse === "always"), ["picked"].some((t) => e.has(t)) && this.picked && (this.clearListOnPick && c(this, o, $).call(this), this.selectedItemIndex = -1), ["searchValue", "minLength"].some((t) => e.has(t)) && x(this, o, ae) && (c(this, o, $).call(this), this.error = void 0), ["focused"].some((t) => e.has(t)) && setTimeout(() => {
|
|
411
411
|
this.focusedDelayed = this.focused, this.clearOnBlur && !this.focused && (this.searchValue = "");
|
|
412
|
-
}, 100), ["selectFirst", "listFeatures", "selectedItemIndex", "picked"].some((t) => e.has(t)) && this.selectFirst !== !1 && this.listFeatures?.length && this.selectedItemIndex == -1 && !this.picked && (this.selectedItemIndex = 0), ["listFeatures", "selectedItemIndex"].some((t) => e.has(t)) && c(this, o, v).call(this, "select", { feature: x(this, o, z) }), ["picked"].some((t) => e.has(t)) && this.picked && (this.fetchFullGeometryOnPick && !this.picked.address && this.picked.geometry.type === "Point" && this.picked.place_type[0] !== "reverse" ? c(this, o, K).call(this, this.picked.id, { byId: !0 }) : Promise.resolve()).then(
|
|
412
|
+
}, 100), ["selectFirst", "listFeatures", "selectedItemIndex", "picked"].some((t) => e.has(t)) && this.selectFirst !== !1 && this.listFeatures?.length && this.selectedItemIndex == -1 && !this.picked && (this.selectedItemIndex = 0), ["listFeatures", "selectedItemIndex"].some((t) => e.has(t)) && c(this, o, v).call(this, "select", { feature: x(this, o, z) }), ["picked"].some((t) => e.has(t)) && this.picked && this.picked.id !== e.get("picked")?.id && (this.fetchFullGeometryOnPick && !this.picked.address && this.picked.geometry.type === "Point" && this.picked.place_type[0] !== "reverse" ? c(this, o, K).call(this, this.picked.id, { byId: !0 }) : Promise.resolve()).then(
|
|
413
413
|
() => {
|
|
414
414
|
c(this, o, v).call(this, "pick", { feature: this.picked });
|
|
415
415
|
},
|
|
@@ -501,7 +501,7 @@ let a = class extends L {
|
|
|
501
501
|
c(this, o, Fe).call(this, e);
|
|
502
502
|
}}
|
|
503
503
|
.missingIconsCache=${x(this, ie)}
|
|
504
|
-
.iconsBaseUrl=${this.iconsBaseUrl ?? "https://cdn.maptiler.com/maptiler-geocoding-control/v3.0.0-rc.
|
|
504
|
+
.iconsBaseUrl=${this.iconsBaseUrl ?? "https://cdn.maptiler.com/maptiler-geocoding-control/v3.0.0-rc.3/icons/"}
|
|
505
505
|
>
|
|
506
506
|
${e.place_name}
|
|
507
507
|
</maptiler-geocoder-feature-item>
|
|
@@ -587,7 +587,7 @@ K = async function(e, { byId: t = !1, exact: i = !1 } = {}) {
|
|
|
587
587
|
).filter((y) => y !== void 0);
|
|
588
588
|
O && (O = [...new Set(O)], m.set("types", O.join(",")));
|
|
589
589
|
const pe = !r || this.reverseGeocodingExcludeTypes === void 0 ? this.excludeTypes : this.reverseGeocodingExcludeTypes;
|
|
590
|
-
if (pe && m.set("excludeTypes", String(pe)), this.bbox && m.set("bbox", this.bbox.map((y) => y.toFixed(6)).join(",")), this.country && m.set("country", Array.isArray(this.country) ? this.country.join(",") : this.country), !t && !r) {
|
|
590
|
+
if (pe && m.set("excludeTypes", String(pe)), this.bbox && m.set("bbox", this.bbox.map((y) => y.toFixed(6)).join(",")), this.country && m.set("country", Array.isArray(this.country) ? this.country.join(",") : this.country), this.worldview && m.set("worldview", this.worldview), !t && !r) {
|
|
591
591
|
const y = this.proximity ?? [{ type: "server-geolocation" }], ue = await Ke(x(this, G), y, n);
|
|
592
592
|
ue && m.set("proximity", ue), (i || this.showResultsWhileTyping === !1) && m.set("autocomplete", "false"), m.set("fuzzyMatch", String(this.fuzzyMatch !== !1));
|
|
593
593
|
}
|
|
@@ -771,6 +771,9 @@ l([
|
|
|
771
771
|
l([
|
|
772
772
|
h({ type: Array })
|
|
773
773
|
], a.prototype, "types", 2);
|
|
774
|
+
l([
|
|
775
|
+
h({ type: String })
|
|
776
|
+
], a.prototype, "worldview", 2);
|
|
774
777
|
l([
|
|
775
778
|
Ue("input")
|
|
776
779
|
], a.prototype, "input", 2);
|
|
@@ -843,7 +846,8 @@ const tt = [
|
|
|
843
846
|
"showPlaceType",
|
|
844
847
|
"showResultsWhileTyping",
|
|
845
848
|
"types",
|
|
846
|
-
"reverseGeocodingTypes"
|
|
849
|
+
"reverseGeocodingTypes",
|
|
850
|
+
"worldview"
|
|
847
851
|
];
|
|
848
852
|
export {
|
|
849
853
|
H as MaptilerGeocodeClearIconElement,
|