Skip to content

Conversation

@ambientlight
Copy link
Member

@ambientlight ambientlight commented Apr 13, 2021

Based on previous #73 and #75, adds support for drawing manager, with the following details:

  • DrawingManagerProvider also contains DataSourceProvider for its manager datasource as a child
  • each customizable drawing manager layer is available as a context provider: AzureMapDrawingLayerProvider which allows customizing layer options and events.
  • fixes Drawing Manager and Indoor Manager #70 (comment) by making sure there are no multiple versions of azure-maps-control in target generated bundle.
  • fixes cannot read children of undefined in _updateMode issue mentioned in feat: add drawing manager tools #75 (comment) by instantiating toolbar control in map ready handler and letting users pass toolbar params rather then toolbarControl instances
  • Additionally yarn peerDependency warnings are fixed.

Sample usage:
NOTE: features added directly into AzureMapDrawingManagerProvider are editable.

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

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

const DefaultMap= () => (
  <AzureMapsProvider>
    <div style={{ height: '100vh' }}>
      <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>
);

export default DefaultMap;

Coverage after added unit tests:

coverage

Playground example is at Azure/react-azure-maps-playground#49

@ambientlight ambientlight marked this pull request as ready for review April 15, 2021 19:02
@ambientlight ambientlight force-pushed the feat/drawing-manager branch from 73aa44c to 3dd618d Compare April 15, 2021 19:11
@psrednicki psrednicki self-requested a review June 4, 2021 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drawing Manager and Indoor Manager

2 participants