AnsweredAssumed Answered

How to reverse geocode with crossroad

Question asked by leo.deng.transfinder on Apr 24, 2016

While using the Locator.locationToAddress function, I got only one record when location-to-address-complete.

When input the corssroad coordinate, actually I hope to return at least two roads names. How I can set the parameters to achieve it?

 

I tried to adjust the distance parameter. It shown that it's the tolerance of accuracy. However, there's still only one or none(the distance is too low) of result.

 

Testing environment:

ArcGIS API for JavaScript v3.16

 

Testing scripts:

<script>
      require([
        "esri/urlUtils", "esri/map", "esri/tasks/locator",
        "dojo/parser",
        "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!"
      ], function(
        urlUtils, Map, Locator,
        parser
      ) {
        parser.parse();

        urlUtils.addProxyRule({
          urlPrefix: "geocode.arcgis.com",
          proxyUrl: "http://localhost/proxy/DotNet/proxy.ashx"
        });

        var map = new Map("map", {
          basemap: "streets",
          center:[-73.93,42.814],
          zoom: 14
        });

        var url = "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/";

        map.on("click", mapClickHandle);

        function mapClickHandle(evt) {

          var attributes = {};
          var stop = evt.mapPoint;  // streets 3857

          var locator = new Locator(url);
          locator.locationToAddress(stop, 100);

          locator.on("location-to-address-complete", function(address)
          {
            console.log(address);

            attributes["F_Address"] = address.address.address.Address;
            attributes["F_City"] = address.address.address.City;
            attributes["F_Region"] = address.address.address.Region;
            attributes["F_SRegion"] = address.address.address.Subregion;
            attributes["F_Postal"] = address.address.address.Postal;
            attributes["F_MAddr"] = address.address.address.Match_addr;
          });

          locator.on("error", function(error)
          {
            console.log("Locator error.");
            console.log(error);
          });
        };
      });
    </script>

Outcomes