get address from co-ordinates on initialization of map

357
0
02-02-2021 08:00 AM
SagarPatil
New Contributor

I am trying to fetch address details by lat long co-ordinates that are provided from DB. I am able to call locationToAddress on click. I want to do the same for on load using the co-ordinates. 

The issue is, SpatialReference that I get on event is missing when I am trying to load on initialization. Below is the sample code, 

 

//what I send for click event

const params = {

            location: evt.mapPoint
            };

//what I am trying to send now since I dont have click event, I am trying to send entire object of that event. statically for now of course.
          const params2 = {location: {
            extent: null,hasM: false,hasZ: false,latitude: 29.9806182045836,longitude: -92.12846434525886,m: undefined,
            spatialReference: {
              imageCoordinateSystem: null,isGeographic: false,isWGS84: false,
              isWebMercator: true,isWrappable: true,latestVcsWkid: null,latestWkid: 3857,
              vcsWkid: null,wkid: 102100,wkt: null,
            },type: "point",x: -10255186.148839561,y: 3501022.9077692255,z: undefined
          }};
          locatorTask.locationToAddress(params2)
          .then(function(response) { // Show the address found
            const address = response.address;
            showPopup(address, evt.mapPoint);
          }, function(err) { // Show no address found
            showPopup("No address found.", evt.mapPoint);
          }).catch((errr)=>{
            console.log(errr)
          });

 

this throws an error in locator JS, 'a.clone' is not a function"

0 Kudos
0 Replies