Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: drawing manager support #93

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

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
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