Set color of polygon with color set in the geojson feature properties#381
Set color of polygon with color set in the geojson feature properties#381benbaumann95 merged 1 commit intomainfrom
Conversation
✅ Deploy Preview for oslmap ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
- Default to geojsonColor is this properties color object does not exist
94e7ee3 to
badfac1
Compare
| : hexToRgba(this.geojsonColor, 0), | ||
| }), | ||
| }), | ||
| style: function (this: MyMap, feature: any) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Yeah still complaining 😕 .
Let me know if you do figure this one out, i'm intrigued now !
jessicamcinchak
left a comment
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 |
"properties": {"color": "#e670fc"}https://trello.com/c/IQsb3WNF/1908-improve-content-and-layout-for-querying-neighbour-addresses-by-polygon-search