Forum Discussion

Joanne520's avatar
Joanne520
Copper Contributor
May 16, 2024

In React (CRA) project, cannot load azure-maps-geolocation-control.js external Azure Map script

I am working with a CRA React project. In a React component, I have tried to import and load an external Azure Map standalone script like https://github.com/Azure-Samples/azure-maps-geolocation-controlwhich adds on to the Azure Map namespace (atlas). In this React component I have imported Azure Map SDK like azure-maps-control which works fine to render the map and supplies the namespace.

 

Under map ready event, I have tried to instantiate GeolocationControl object but seems like the script cannot read the atlas namespace. This external script is placed in public folder and dynamically placed in <head> of index.html .

 

How to make the script link to Azure Map SDK namespace, in a React component? Thank you

In React functional component

Resources