@nextgis/geocoder 1.16.8 → 1.18.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 CHANGED
@@ -2,7 +2,13 @@
2
2
 
3
3
  ![size](https://img.shields.io/bundlephobia/minzip/@nextgis/geocoder) ![version](https://img.shields.io/npm/v/@nextgis/geocoder)
4
4
 
5
- Modern geocoder on async generators. May use different data providers.
5
+ Geocoder is a versatile library designed for intuitive geocoding functionalities.
6
+ With an emphasis on ease-of-use, it supports multiple providers to cater to diverse requirements, allowing developers to seamlessly integrate geocoding into their applications.
7
+
8
+ ## Built-in providers
9
+
10
+ - NgwProvider: Specifically for the NGW vector layer, ideal for applications that rely on NextGIS services.
11
+ - NominatimProvider: Utilizes the Nominatim geocoding service, suitable for applications requiring free geocoding services with OpenStreetMap data.
6
12
 
7
13
  ## Installation
8
14
 
@@ -48,12 +54,41 @@ $ yarn add @nextgis/geocoder
48
54
 
49
55
  ## Usage
50
56
 
51
- ```javascript
52
- import { Geocoder } from '@nextgis/geocoder';
57
+ ### Basic Usage with NGW Provider
53
58
 
54
- const ngwConnector = new Geocoder({
55
- ...options
59
+ ```javascript
60
+ import { Geocoder, NgwProvider } from '@nextgis/geocoder';
61
+
62
+ // Initialize the NGW Provider
63
+ const ngwProvider = new NgwProvider({
64
+ connectorOptions: {
65
+ baseUrl: 'https://demo.nextgis.com',
66
+ },
67
+ searchResources: [
68
+ {
69
+ resourceId: 4224,
70
+ limit: 3,
71
+ },
72
+ // ... other resources
73
+ ],
56
74
  });
75
+
76
+ // Initialize the geocoder
77
+ const geocoder = new Geocoder({ providers: [ngwProvider] });
78
+
79
+ // Use geocoder.search() for geocoding queries
80
+ const searchQuery = "example_search_query"; // Replace with your search term
81
+ const geocoderGenerator = geocoder.search(searchQuery);
82
+
83
+ // Iterate over the geocoder generator to get the search results
84
+ for await (const item of geocoderGenerator) {
85
+ console.log(item.text); // Log the item name or description
86
+ item.result().then(({ extent }) => {
87
+ // Use the result's extent or other properties as needed
88
+ console.log(extent);
89
+ });
90
+ break;
91
+ }
57
92
  ```
58
93
 
59
94
  Check out the [API Documentation](https://code-api.nextgis.com/modules/geocoder.html)