Installation
Map Setup
To inject react-azure-maps to your React App you must just add package by your package manager and get Azure Map subscription key
Get an Azure Maps key at https://azure.com/maps
NPM
npm install react-azure-maps
Yarn
yarn add react-azure-maps
Basic Usage
Create IAzureMapOptions
object with you key
and initial map properties then pass it as options props in Azure Map. AzureMap component should be wrap by AzureMapProvider
. Map also must have contiarner that specifies the height of the map.
const option: IAzureMapOptions = {
authOptions: {
authType: AuthenticationType.subscriptionKey,
subscriptionKey: key
},
}
const DefaultMap: React.FC = () => (
<div style={{height: '300px'}}>
<AzureMapsProvider>
<AzureMap options={option}>
</AzureMap>
</AzureMapsProvider>
</div>
)