Restrict geocoder to extent

2888
1
Jump to solution
03-18-2015 09:22 AM
SébastienMartin
New Contributor III

Hi,

I'm trying to customize the geocoder of an application made with WebAppBuilder. I changed the config.JSON file in the Geocoder folder to:

{  
  "geocoder": {  
    "autoComplete": true,  
    "minCharacters": 3,  
    "name": "Esri World Geocoder",  
    "arcgisGeocoder": false,  
    "geocoders": [  
      {  
        "url": "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer",  
        "name": "Esri World Geocoder",  
        "singleLineFieldName": "SingleLine",  
        "placeholder": "Chercher une adressse",  
        "searchExtent": {
                "xmin":-8057000,
                "ymin":5620600,
                "xmax":-7910000,
                "ymax":5681500,
                "spatialReference":{"wkid":102100}
        }
      }  
    ]  
  }  
} 

When I set "arcgisGeocoder" to true,

  • Geocoder selection dropdown menu
  • No placeholder text, which is annoying
  • Results related to the specified extent when I start typing (which is what I'm looking for)

When I set "arcgisGeocoder" to false,

  • No geocoder selection dropdown menu
  • Placeholder text
  • No results appearing when I start typing (just that thing going round)

Somebody knows what's wrong in the code? (I tried everything!) I want:

  • No geocoder selection menu
  • Placeholder text
  • Results when I start typing

Thanks for your help

0 Kudos
1 Solution

Accepted Solutions
SébastienMartin
New Contributor III

I figured it out myself, adding:

"geocoderMenu": false,

to get rid of the geocoder selection menu, and

"arcgisGeocoder": {
  "placeholder": "Chercher une adresse"
},

to get the placeholder text back.

Here's the full code:

{  
  "geocoder": {  
    "autoComplete": true,  
    "minCharacters": 3,  
    "name": "Esri World Geocoder",  
    "arcgisGeocoder": true,
    "geocoderMenu": false,
    "arcgisGeocoder": {
      "placeholder": "Chercher une adresse"
    },
    "geocoders": [  
      {  
        "url": "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer",  
        "name": "Esri World Geocoder",  
        "singleLineFieldName": "SingleLine",  
        "searchExtent": {
                "xmin":-8057000,
                "ymin":5620600,
                "xmax":-7910000,
                "ymax":5681500,
                "spatialReference":{"wkid":102100}
        }
      }  
    ]  
  }  
} 

View solution in original post

1 Reply
SébastienMartin
New Contributor III

I figured it out myself, adding:

"geocoderMenu": false,

to get rid of the geocoder selection menu, and

"arcgisGeocoder": {
  "placeholder": "Chercher une adresse"
},

to get the placeholder text back.

Here's the full code:

{  
  "geocoder": {  
    "autoComplete": true,  
    "minCharacters": 3,  
    "name": "Esri World Geocoder",  
    "arcgisGeocoder": true,
    "geocoderMenu": false,
    "arcgisGeocoder": {
      "placeholder": "Chercher une adresse"
    },
    "geocoders": [  
      {  
        "url": "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer",  
        "name": "Esri World Geocoder",  
        "singleLineFieldName": "SingleLine",  
        "searchExtent": {
                "xmin":-8057000,
                "ymin":5620600,
                "xmax":-7910000,
                "ymax":5681500,
                "spatialReference":{"wkid":102100}
        }
      }  
    ]  
  }  
}