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:
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?
Solved! Go to Solution.
Hi @Blakearc most likely the View isn't ready (view.ready === false) when you try to initialize the Locate widget. If you are still having issues after looking into that, you'll need to provide a focused, working github repo, stackblitz or codesandbox example of your React project. Here a basic troubleshooting guide: https://github.com/Esri/jsapi-resources/blob/main/TROUBLESHOOTING.md#four-triage-steps.
Hi @Blakearc most likely the View isn't ready (view.ready === false) when you try to initialize the Locate widget. If you are still having issues after looking into that, you'll need to provide a focused, working github repo, stackblitz or codesandbox example of your React project. Here a basic troubleshooting guide: https://github.com/Esri/jsapi-resources/blob/main/TROUBLESHOOTING.md#four-triage-steps.
Thank you for answering. I put the locate() into view.when() and it works now !