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

Set color of polygon with color set in the geojson feature properties #381

Merged
merged 1 commit into from
Sep 1, 2023

Conversation

benbaumann95
Copy link
Collaborator

@benbaumann95 benbaumann95 commented Aug 31, 2023

  • Default to geojsonColor if the properties color object does not exist
  • Can be added to feature i.e. "properties": {"color": "#e670fc"}

https://trello.com/c/IQsb3WNF/1908-improve-content-and-layout-for-querying-neighbour-addresses-by-polygon-search

Screenshot 2023-08-31 at 12 45 59

@netlify
Copy link

netlify bot commented Aug 31, 2023

Deploy Preview for oslmap ready!

Name Link
🔨 Latest commit badfac1
🔍 Latest deploy log https://app.netlify.com/sites/oslmap/deploys/64f07e26eedd8000080d6544
😎 Deploy Preview https://deploy-preview-381--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 configuration.

- Default to geojsonColor is this properties color object does not exist
@benbaumann95 benbaumann95 force-pushed the add-properties-colour branch from 94e7ee3 to badfac1 Compare August 31, 2023 11:48
: hexToRgba(this.geojsonColor, 0),
}),
}),
style: function (this: MyMap, feature: any) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Was struggling to add the specific type for feature.
Tried adding feature: Feature and feature: typeof Feature with no luck even though this is an instance of Feature

Copy link
Member

Choose a reason for hiding this comment

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

No worries here, OpenLayers can be finiky about this - it might be:

import { Feature } from "ol/index";

style: function (this: MyMap, feature: Feature<Geometry>) {...}

But if that still complains, feel free to leave this as any and I can re-visit later!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah still complaining 😕 .
Let me know if you do figure this one out, i'm intrigued now !

Copy link
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

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

Thanks again for this ! Tested and works perfectly 🎨

Left a small type suggestion, but no pressure to spend time on that if not straightforward. Happy for this to be "Squashed & merged" anytime and I'll get the new release through before end of day for you!

: hexToRgba(this.geojsonColor, 0),
}),
}),
style: function (this: MyMap, feature: any) {
Copy link
Member

Choose a reason for hiding this comment

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

No worries here, OpenLayers can be finiky about this - it might be:

import { Feature } from "ol/index";

style: function (this: MyMap, feature: Feature<Geometry>) {...}

But if that still complains, feel free to leave this as any and I can re-visit later!

}),
style: function (this: MyMap, feature: any) {
// Retrieve color from feature properties
let featureColor = feature.get("color") || this.geojsonColor; // Use the geojsonColor if no color property exists
Copy link
Member

Choose a reason for hiding this comment

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

🙌 smart & simple !

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