Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/examples/DrawingTools.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from "react";

import { AzureMap, AzureMapsProvider, AzureMapDrawingManagerProvider, AzureMapFeature, AzureMapDrawingLayerProvider, IAzureMapOptions } from 'react-azure-maps';
import { AuthenticationType } from 'azure-maps-control';
import { key } from "../key";
import { wrapperStyles } from "./RouteExample";

const styles = {
map: {
height: 600,
marginBottom: 50,
},
};

const option: IAzureMapOptions = {
center: [-122.33, 47.6],
zoom: 12,
authOptions: {
authType: AuthenticationType.subscriptionKey,
subscriptionKey: key,
},
};

const drawingOptions = {
toolbar: {
position: 'top-right',
style: 'dark',
}
};

const DrawingTools: React.FC = () => (
<div style={wrapperStyles.map}>
<AzureMapsProvider>
<div style={styles.map}>
<AzureMap options={option}>
<AzureMapDrawingManagerProvider options={drawingOptions}>
<AzureMapFeature
id={'DrawingTool MapFeature'}
type="Polygon"
coordinates={[
[-122.33, 47.6],
[-122.43, 47.6],
[-122.43, 47.7],
[-122.33, 47.6],
]}
/>

<AzureMapDrawingLayerProvider type="lineLayer" options={{strokeColor: 'red', strokeWidth: 4}}/>
<AzureMapDrawingLayerProvider type="pointLayer" options={{iconOptions: { image: 'marker-blue' }}}/>
<AzureMapDrawingLayerProvider type="polygonLayer" options={{fillColor: 'green'}}/>
<AzureMapDrawingLayerProvider type="polygonOutlineLayer" options={{strokeColor: 'orange'}}/>
</AzureMapDrawingManagerProvider>
</AzureMap>
</div>
</AzureMapsProvider>
</div>
);

export default DrawingTools;
6 changes: 6 additions & 0 deletions src/examples/examplesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ChangeOptionsWrapper from './Options/ChangeOptionsWrapper';
import MapWrapper from './MapRef/MapWrapper';
import Building3d from './Buildings3D';
import CustomTrafficVectorDatasourceExample from './CustomTrafficVectorDatasourceExample';
import DrawingTools from './DrawingTools';

export type MapExampleItem = {
name: string;
Expand Down Expand Up @@ -138,5 +139,10 @@ export const examplesList: MapExampleItem[] = [
name: 'Vector Tile Datasource Traffic',
component: CustomTrafficVectorDatasourceExample,
path: '/custom-traffic'
},
{
name: 'Drawing Tools',
component: DrawingTools,
path: '/drawing-tools',
}
];