AnsweredAssumed Answered

Cannot access geometry of the locator point ArcGIS JS 4.X

Question asked by agole_waterboards on Sep 10, 2018
Latest reply on Sep 10, 2018 by agole_waterboards

Hi all,

I am trying to get the locator work on Javascript 4.X but I am having trouble getting it to work. I am using th

 

Here is my starting script:

 

//Set the locator here
            var locator = new Locator({ url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer" });
            var geom;
            var addressParams = {
                "SingleLine": "1001 I street, Sacramento"
            };

            $("#locate").click(function () {
                locator.addressToLocations({ address: addressParams }).then(function (evt) {
                    console.log(evt);
                    var symbol = {
                        type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
                        style: "square",
                        color: "blue",
                        size: "8px",  // pixels
                        outline: {  // autocasts as new SimpleLineSymbol()
                            color: [255, 255, 0],
                            width: 3  // points
                        }
                    };
                    geom = evt.location;
                    console.log(geom);
                    var graphic = new Graphic({
                        geometry: geom,
                        symbol: symbol,
                    });

                    view.graphics.add(graphic);
                });
            });

 

 

It is returning this in console 

 

 

However this returns as undefined. Any clue?

geom = evt.location;
                    console.log(geom);

 

 

Thanks,

Alex

Outcomes