Skip to content

feat: enable drawing single point#232

Merged
jessicamcinchak merged 1 commit intomainfrom
jess/support-single-point-drawing
Dec 9, 2022
Merged

feat: enable drawing single point#232
jessicamcinchak merged 1 commit intomainfrom
jess/support-single-point-drawing

Conversation

@jessicamcinchak
Copy link
Copy Markdown
Member

@jessicamcinchak jessicamcinchak commented Dec 8, 2022

Context:

  • drawMode previously assumed the geometry type "Polygon" because we've only used it for drawing site boundaries
  • now, we want to support an additional drawing mode where you can plot a single point on the map to denote a "new address"
  • i think it's safe to assume that we don't need to support drawing a polygon and point at the same time on a single map, so these functionalities can share a source

Changes:

  • adds optional prop drawType to specify "Polygon" (default) or "Point" when using drawMode
  • adds optional prop drawPointColor to specify the color of the feature
  • only displays snap points when drawing a "Polygon"
  • only dispatches the areaChange event when drawing a "Polygon"
  • otherwise "Point" drawing carries the same assumptions as "Polygon": limit to 1 feature, ability to modify after plotted, can be "reset", will dispatch a geojsonChange event

To test:

<my-map drawMode drawType="Point" />

Future scope:

  • clean up point styling, make more customizable?
  • dispatch a point-specific change event with the coordinates in both EPSG:4326 & BNG ? for now, planx will just read from the geojson but i can imagine in the future we may want to be better aligned to Ordnance Survey format for existing addresses

@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 8, 2022

Deploy Preview for oslmap ready!

Name Link
🔨 Latest commit bed0369
🔍 Latest deploy log https://app.netlify.com/sites/oslmap/deploys/639204b78c39e40008ff80a1
😎 Deploy Preview https://deploy-preview-232--oslmap.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@jessicamcinchak jessicamcinchak requested a review from a team December 8, 2022 15:41
@jessicamcinchak
Copy link
Copy Markdown
Member Author

Copy link
Copy Markdown
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, always good to see a simple PR that offers a solid bit of extra functionality 👏

import { StyleLike } from "ol/style/Style";
import { pointsSource } from "./snapping";

export type DrawTypeEnum = "Polygon" | "Point"; // ref https://openlayers.org/en/latest/apidoc/module-ol_geom_Geometry.html#~Type
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

});

export const drawingSource = new VectorSource();
const boundaryLayerStyle: StyleLike = [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there might be future scope for extracting these out into a style.ts or similar 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep totally fair, definitely getting a bit cluttered as-is !

@jessicamcinchak jessicamcinchak merged commit 541bcdb into main Dec 9, 2022
@jessicamcinchak jessicamcinchak deleted the jess/support-single-point-drawing branch December 9, 2022 12:58
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.

2 participants