NextGIS Frontend
    Preparing search index...

    Module @nextgis/geocoder

    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.

    • 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.

    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>

    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]

    npm install @nextgis/geocoder
    
    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

    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

    Classes

    BaseProvider
    Geocoder
    NgwProvider
    NominatimProvider

    Interfaces

    BaseProviderOptions
    GeocoderOptions
    ResultItem
    SearchItem

    Functions

    create