I have setup a simple map with a default search widget, similar to this:

  "esri/map", "esri/dijit/Search", ... 
], function(Map, Search, ...) {
  var map = new Map(...);
  var s = new Search({
    map: map

In my web browser, using the widget, I want to search for a location using latitude longitude coordinates (lat,lon), but it seems that the widget requires longitude first (lon,lat) when searching by coordinates. Is there any way to configure the widget to take the lat,lon format? Or would this have to be configured on the server side service that the widget is calling?

  • What version of the ArcGIS API for JavaScript are you using?
    – GavinR
    Jun 21 '17 at 16:43
  • I'm using ArcGIS JS version 3.15
    – dave823
    Jun 21 '17 at 17:17
  • What (lat,lon) search is not working for you?
    – GavinR
    Jun 21 '17 at 19:21
  • If I enter coordinates in the default search widget in the format lat,lon, the search treats the first number as longitude and the second number after the comma as latitude, but i want it to treat the first number as latitude, and the second number as longitude.
    – dave823
    Jun 21 '17 at 20:04

For me, the search widget is working how I would like it to work:

  1. If it can determine based on the values of your lat/lon that you have put it in backwards, it will take you to the correct location (automatically switch them) instead of giving an error. For example, searching 41.603121,-96.591797 and -96.591797,41.603121 in this example brings you to the same place.
  2. If you are using a lat,lon that could go either way, it assumes (lon,lat) as you said, but the popup has a convenient "did you mean?" notice: enter image description here

Now if you want to change the default order in the case of #2 so it tries to guess "lat,lon" first, there are a variety of ways to do this. There may be better solutions, but one option is to extend the search widget using dojo/declare and define your own function for the search method, like here. (you'll notice in that code that if you search 22.502407,-78.222656 from above, it will first take you to the ocean by Cuba instead of Antartica like it does using the example from 1.)

  • 1
    The example code you gave to default to lat,lon is perfect. Thanks!
    – dave823
    Jun 22 '17 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.