perliedman / leaflet-control-geocoder

A simple geocoder form to locate places. Easily extended to multiple data providers.
http://www.liedman.net/leaflet-control-geocoder/
BSD 2-Clause "Simplified" License
567 stars 222 forks source link

Add suggestion support for HERE. #274

Closed ryan-morris closed 11 months ago

ryan-morris commented 4 years ago

I've added support for getting suggestions with the HERE geocode provider.

The primary issue with the HERE api response is that there is no coordinate information on the response (see below). In theory a provider that offers a suggestion should be able to look up that exact suggestion. So I also adjusted the control to call setQuery and trigger a _geocode request when selecting a suggestion with no bbox or center. Let me know if it's better to find a way around this approach.

{
    "suggestions": [
        {
            "label": "United States, GA, Atlanta",
            "language": "en",
            "countryCode": "USA",
            "locationId": "NT_fw7oye40be288veJdXfo8D",
            "address": {
                "country": "United States",
                "state": "GA",
                "county": "Fulton",
                "city": "Atlanta",
                "postalCode": "30303"
            },
            "matchLevel": "city"
        },
        {
            "label": "México, Cuautitlán Izcalli, Atlanta",
            "language": "es",
            "countryCode": "MEX",
            "locationId": "NT_CZjO39V8qEqSvz-TcADJxC",
            "address": {
                "country": "México",
                "state": "EDOMEX",
                "city": "Cuautitlán Izcalli",
                "district": "Atlanta",
                "postalCode": "54740"
            },
            "matchLevel": "district"
        },
        {
            "label": "Deutschland, Remseck am Neckar, Atlantastraße",
            "language": "de",
            "countryCode": "DEU",
            "locationId": "NT_7OkjmvLRX63KZeLmTW-48D",
            "address": {
                "country": "Deutschland",
                "state": "Baden-Württemberg",
                "county": "Ludwigsburg",
                "city": "Remseck am Neckar",
                "district": "Pattonville",
                "street": "Atlantastraße",
                "postalCode": "71686"
            },
            "matchLevel": "street"
        },
        {
            "label": "United States, GA, Atlanta, Atlanta University Center",
            "language": "en",
            "countryCode": "USA",
            "locationId": "NT_1E366mzP4hMOPK4LS6R.2A",
            "address": {
                "country": "United States",
                "state": "GA",
                "county": "Fulton",
                "city": "Atlanta",
                "district": "Atlanta University Center",
                "postalCode": "30314"
            },
            "matchLevel": "district"
        },
        {
            "label": "United States, TX, Atlanta",
            "language": "en",
            "countryCode": "USA",
            "locationId": "NT_PS1qFrX6QAmUhmXiCGE57A",
            "address": {
                "country": "United States",
                "state": "TX",
                "county": "Cass",
                "city": "Atlanta",
                "postalCode": "75551"
            },
            "matchLevel": "city"
        }
    ]
}
ryan-morris commented 11 months ago

HERE has since changed their APIs and the one currently in use is set to stop working Dec 1.