@nextgis/geocoder
TypeScript icon, indicating that this package has built-in type declarations

2.1.1 • Public • Published

Geocoder

size version

Geocoder is a versatile library designed for intuitive geocoding functionalities. 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.

Built-in providers

  • NgwProvider: Specifically for the NGW vector layer, ideal for applications that rely on NextGIS services.
  • NominatimProvider: Utilizes the Nominatim geocoding service, suitable for applications requiring free geocoding services with OpenStreetMap data.

Installation

In Browser

Include assets

Simply download and include with a script tag, Geocoder will be registered as a global variable.

<script src="../lib/geocoder.global.js"></script>

<script>
  var geocoder = Geocoder.create({
    ...options
  });
</script>

CDN

unpkg

<script src="https://unpkg.com/@nextgis/geocoder"></script>

jsdelivr

<script src="https://cdn.jsdelivr.net/npm/@nextgis/geocoder"></script>

We recommend linking to a specific version number /geocoder@[version]

In Node.js

npm install @nextgis/geocoder

Usage

Basic Usage with NGW Provider

import { Geocoder, NgwProvider } from '@nextgis/geocoder';

// Initialize the NGW Provider
const ngwProvider = new NgwProvider({
    connectorOptions: {
        baseUrl: 'https://demo.nextgis.com',
    },
    searchResources: [
        {
            resourceId: 4224,
            limit: 3,
        },
        // ... other resources
    ],
});

// Initialize the geocoder
const geocoder = new Geocoder({ providers: [ngwProvider] });

// Use geocoder.search() for geocoding queries
const searchQuery = "example_search_query"; // Replace with your search term
const geocoderGenerator = geocoder.search(searchQuery);

// Iterate over the geocoder generator to get the search results
for await (const item of geocoderGenerator) {
    console.log(item.text); // Log the item name or description
    item.result().then(({ extent }) => {
        // Use the result's extent or other properties as needed
        console.log(extent);
    });
    break;
}

Check out the API Documentation

Commercial support

Need to fix a bug or add a feature to @nextgis/geocoder? We provide custom development and support for this software. Contact us to discuss options!

http://nextgis.com

Readme

Keywords

Package Sidebar

Install

npm i @nextgis/geocoder

Weekly Downloads

8

Version

2.1.1

License

MIT

Unpacked Size

1.03 MB

Total Files

21

Last publish

Collaborators

  • rendrom
  • maximdubinin
  • karavanjo