You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently Draw is tightly coupled with the GeoJSON spec. I've long defended this decision because I think it helps reduce bugs by limiting the surface area Draw needs to manage to the GeoJSON spec. That said, a few months back @flippmoke, @sgillies and myself had a conversation about the vector tile spec that made me start to question if the job of Draw is to create good GeoJSON or if its to create data to be rendered to the map which could be any content type than can be turned in the vector tiles.
Anyway, while time has not given me clarity on how Draw might change to create VT rather than GeoJSON, considering the consequences of such a shift has convinced me that user defined Custom Shapes should be a thing in Draw just like Custom Modes.
Some custom shapes that I have in mind are:
Square
Triangle
Hexagon
Circle
You know, simple things people have asked for for a long time but I've said no to because they aren't in the GeoJSON spec.
Why custom
The main problem I've long had with the out of spec shape suggestions is that they all depend on adding a magic property to a Feature. While this is a great idea (really) the fact is that much of the GeoJSON users drop into Draw wasn't created by them and thus might use said magic property for different reasons.
That said, as a developer, you should have the power to create great software despite the above problem and, the best way I see to do that well, is custom shapes.
How would these work
Like we did with modes when creating the custom modes, the Draw API would need to expose a way to change the list of shapes by passing your own JS objects into Draw. For modes we let you drop the core modes if you wanted to, for shapes we'd continue to require Point, LineString, Polygon and their Multi* counterparts to stay.
Part of the Custom Shape interface would be a function that takes a GeoJSON Feature and returns true or false to indicate if this GeoJSON matches the Custom Shapes convention like the code below.
varsquare={};customShape.featureIsShape=function(feature){// This would be a pretty poor checkreturnfeature.properties.type==='square';}
Would draw_polygon make my shape?
Nope. Custom Shape creators would likely want to create a Custom Mode to draw their shapes.
Next Steps
Does this sound like a good idea to other users out in the wild? If not, please explain what your concerns are below. If so, do you have any time to put into helping make this happen either via PRs or brainstorming?
The text was updated successfully, but these errors were encountered:
If they're more like icons, there is some perhaps-relevant discussion in the gridded-data ticket for the vector tile spec: mapbox/vector-tile-spec#50 (comment)
Instead of having the magic in properties it might be better to have another set of feature characteristics at the top level of the Feature object, maybe a mapbox object where we contain whatever GeoJSON extensions Mapbox products might need. I feel like properties ought to belong to the user, not the implementation.
I assume that there are more like polygons. The key thing here though would be creating a module interface so users can bring their own ideas into Draw.
Instead of having the magic in properties it might be better to have another set of feature characteristics at the top level of the Feature object
This is a great suggestion and if we run out Custom Shapes would be a nice thing to put in the docs/examples for how to make them.
Currently Draw is tightly coupled with the GeoJSON spec. I've long defended this decision because I think it helps reduce bugs by limiting the surface area Draw needs to manage to the GeoJSON spec. That said, a few months back @flippmoke, @sgillies and myself had a conversation about the vector tile spec that made me start to question if the job of Draw is to create good GeoJSON or if its to create data to be rendered to the map which could be any content type than can be turned in the vector tiles.
Anyway, while time has not given me clarity on how Draw might change to create VT rather than GeoJSON, considering the consequences of such a shift has convinced me that user defined Custom Shapes should be a thing in Draw just like Custom Modes.
Some custom shapes that I have in mind are:
You know, simple things people have asked for for a long time but I've said no to because they aren't in the GeoJSON spec.
Why custom
The main problem I've long had with the out of spec shape suggestions is that they all depend on adding a magic property to a Feature. While this is a great idea (really) the fact is that much of the GeoJSON users drop into Draw wasn't created by them and thus might use said magic property for different reasons.
That said, as a developer, you should have the power to create great software despite the above problem and, the best way I see to do that well, is custom shapes.
How would these work
Like we did with modes when creating the custom modes, the Draw API would need to expose a way to change the list of shapes by passing your own JS objects into Draw. For modes we let you drop the core modes if you wanted to, for shapes we'd continue to require Point, LineString, Polygon and their Multi* counterparts to stay.
Part of the Custom Shape interface would be a function that takes a GeoJSON Feature and returns
true
orfalse
to indicate if this GeoJSON matches the Custom Shapes convention like the code below.Would
draw_polygon
make my shape?Nope. Custom Shape creators would likely want to create a Custom Mode to draw their shapes.
Next Steps
Does this sound like a good idea to other users out in the wild? If not, please explain what your concerns are below. If so, do you have any time to put into helping make this happen either via PRs or brainstorming?
The text was updated successfully, but these errors were encountered: