mapbox-gl-geocoder icon indicating copy to clipboard operation
mapbox-gl-geocoder copied to clipboard

How to fill the adress result field of the geocoder ?

Open MatteoGauthier opened this issue 3 years ago • 1 comments

Hey, I wanted to know how to fill the address field in the geocoding results

On the screenshot, the first two results don't have an address field.

Capture d’écran 2022-06-02 à 14 46 58

Yet here is the local search result sent to the geocoder :

[
    {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [
                "-3.8242604",
                "48.5614347"
            ]
        },
        "properties": {
            "title": "PHARMACIE KERBORIOU",
            "adresse": "PLATEAU SAINT FIACRE 29600 PLOURIN LES MORLAIX ",
            "phone": null
        },
        "id": "PHARMACIE KERBORIOU-PLATEAU SAINT FIACRE 29600 PLOURIN LES MORLAIX ",
        "text": "PLATEAU SAINT FIACRE 29600 PLOURIN LES MORLAIX ",
        "place_name": "PHARMACIE KERBORIOU",
        "center": [
            "-3.8242604",
            "48.5614347"
        ],
        "place_type": [
            "park"
        ],
        "address": "PLATEAU SAINT FIACRE 29600 PLOURIN LES MORLAIX ",
        "context": [
            {
                "id": "PLATEAU SAINT FIACRE 29600 PLOURIN LES MORLAIX ",
                "text": "Texas"
            }
        ]
    },
    {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [
                "-1.679236",
                "48.10486"
            ]
        },
        "properties": {
            "title": "GRANDE PHARMACIE DE RENNES – BOTICINAL",
            "adresse": "10 PLACE DU COLOMBIER 35000 RENNES ",
            "phone": "02 99 31 48 37"
        },
        "id": "GRANDE PHARMACIE DE RENNES – BOTICINAL-10 PLACE DU COLOMBIER 35000 RENNES ",
        "text": "10 PLACE DU COLOMBIER 35000 RENNES ",
        "place_name": "GRANDE PHARMACIE DE RENNES – BOTICINAL",
        "center": [
            "-1.679236",
            "48.10486"
        ],
        "place_type": [
            "park"
        ],
        "address": "10 PLACE DU COLOMBIER 35000 RENNES ",
        "context": [
            {
                "id": "10 PLACE DU COLOMBIER 35000 RENNES ",
                "text": "Texas"
            }
        ]
    }
]

How can I fill the address field of the geocoder results.

Can someone help me ?

Bye

MatteoGauthier avatar Jun 02 '22 12:06 MatteoGauthier

Hello @MatteoGauthier . You can find here how we render the list. We use param place_name. You can also redefine the render function for your specific use case.

krydima avatar Jun 03 '22 13:06 krydima