Select to view content in your preferred language

Locator's addressToLocations() function is receiving unrelated response

1830
4
04-19-2018 12:55 AM
NisarAhmed
Emerging Contributor

I'm using the following code (v 4.6) to geocode an address:

var locatorTask = new Locator({
});
var addressParams = {
   "singleLine": "915 I St, Sacramento, CA"
};
locatorTask.addressToLocations({address:addressParams}).then(function(response){
   console.log(response);
});
This is what I'm getting in the browser console:
Console
What I'm missing here? I should be getting Same URL used in browser address bar
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Nisar,

  When I added you lines of code above to one of the 4.x API sample it worked fine for me.

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <title>Intro to MapView - Create a 2D map - 4.6</title>
  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }
  </style>

  <link rel="stylesheet" href="https://js.arcgis.com/4.6/esri/css/main.css">
  <script src="https://js.arcgis.com/4.6/"></script>

  <script>
    require([
      "esri/Map",
      "esri/views/MapView",
      "esri/tasks/Locator",
      "dojo/domReady!"
    ], function(Map, MapView, Locator) {

      var map = new Map({
        basemap: "streets"
      });

      var view = new MapView({
        container: "viewDiv",
        map: map,
        zoom: 4,
        center: [15, 65] // longitude, latitude
      });
      
      var locatorTask = new Locator({
         url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"
      });
      var addressParams = {
         "singleLine": "915 I St, Sacramento, CA"
      };
      locatorTask.addressToLocations({address:addressParams}).then(function(response){
         console.log(response);
      });

    });
  </script>
</head>

<body>
  <div id="viewDiv"></div>
</body>
</html>

It returned this

0 Kudos
NisarAhmed
Emerging Contributor

That's odd. Perhaps I have accidentally turned off/on some feature in Firefox settings that is messing with the console output. I checked the same thing in Chrome console and it was showing the data as expected. 

Not sure how I messed up Firefox though.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nisar,

   The way that FF console report the object is different but the data is still there:

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.

0 Kudos