AnsweredAssumed Answered

Why Address is showing as undefined?

Question asked by manjarigoyal on May 10, 2017
Latest reply on Jul 21, 2017 by manjarigoyal

I am trying to click on map and get lat, long and address in one popup window, but its not getting the address. Attached is the screenshot. Any help is appreciated.

 

 

var locator = new Locator("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer");
     var infoTemplate = new InfoTemplate("Location", "Address: ${Address}<br/>" +
     "City: ${City}<br/>" +
     "State: ${Region}<br/>");
     var symbol = new SimpleMarkerSymbol().setStyle(
      SimpleMarkerSymbol.STYLE_CIRCLE).setColor(
      new Color([0,0,255,0.5])
      );
     locator.on("location-to-address-complete", function(evt) {
      map.graphics.clear();
      console.log(evt);
       if (evt.address.address) {
      var address = evt.address.address;
      var location = webMercatorUtils.geographicToWebMercator(evt.address.location);
      var graphic = new Graphic(location, symbol, address, infoTemplate);
      map.graphics.add(graphic);
     var screenPnt = map.toScreen(location);
      map.infoWindow.resize(300,100);
       } 
     });
     map.on("click", function(evt) {
     map.infoWindow.setTitle("Coordinates/Address");
     map.infoWindow.setContent("lat/lon : " + evt.mapPoint.y.toFixed(3) + ", " + evt.mapPoint.x.toFixed(3) + "<br>Address: " + evt.mapPoint.address);
     map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint));
     });

Attachments

Outcomes