I am using ArcGIS with react. I have successfully displayed a map and now I want to get current location once the map is loaded. I included all the setup inside a useEffect hook. I configured the location widget as below:
const locateWidget = new ArcGISLocate({
view: view,
useHeadingEnabled: false,
goToOverride: function (view, options) {
options.target.scale = 1500;
return view.goTo(options.target);
},
});
locateWidget.locate().then(function () {
console.log("success");
});
However I got the following error return:
details: undefined
message: "Cannot locate when disabled."
name: "locate:disabled-state"
I tried using HTTPS over HTTP but the error still exists. How to solve this problem?