Conversation
|
Exciting! Ping me if you want a code review once this nears a shippable state. |
src/events.js
Outdated
| @@ -0,0 +1,97 @@ | |||
| var ModeHandler = require('./modes/mode_handler'); | |||
| var browse = require('./modes/browse'); | |||
| var findTaragetAt = require('./lib/find_target_at'); | |||
|
Any particular reason for moving away from ES6 syntax? |
|
@kelvinabrokwa classes make hiding private vars via closures pretty hard, but most of the other changes are just my default writing style coming through. In time I'd like to find which syntax is best for perf and go with that in the places it maters. Please feel free to suggests syntax changes you think would help. |
e6acb30 to
8d7d87e
Compare
f35149b to
f2c7044
Compare
|
I've spent the day trying to outline the api this branch is working towards into the api.md doc. I'd love some input on this as I continue to work. It is a pretty big shift in how Draw works so making sure it lets you do things like Thanks! /cc @lucaswoj @kirach @drewbo @kelvinabrokwa @averas @tmcw @scothis @mayagao |
|
Great progress @mcwhittemore! I will give it a more thorough review but one thing that immediately caught my attention is the somewhat ambiguous description of id's. It says in the description of the To minimise confusion it's perhaps also best to either base the examples on features, or rename the variables to "geojson" etc., where you in fact are not passing in features. |
|
@mcwhittemore Will the new styling for points allow for sprites? I think from a user perspective, lets say you are editing a layer which is styled with a icon/sprite, you'd probably expect when you add a new point that it looks the same and therefore creates an icon/sprite rather than a circle. |
API.md
Outdated
| ###`.add(Object: GeoJSONFeature) -> String` | ||
|
|
||
| The second argument is an optional options object to add information to the geometry when creating the new element. Currently the only used option is `permanent`, which, if set to true, will cause the element to ignore click events, `Draw.select(:id:)` and `Draw.selectAll()`. | ||
| This method takes any valid GeoJSON and adds it to Draw. The object will be turned into a GeoJSON feature and will be assigned a unique `id that can be used to identify it. This method return `feature.id`. If an id is provided with the feature that ID will be used. |
There was a problem hiding this comment.
s/return/returns (tiny typo)
@averas thanks for point this out. I'll try to clear up ids later today and ping you for feedback when I think I have a good handle on it.
@averas yea, I was feeling feature fatigue when I wrote this. GeoJSON is a good move. I think we're going to need to solve this in the code too.
@joedjc Yep. I'm pretty sure this is currently possible as well. Draw doesn't ship with sprites though, so you'd need to make sure they are included at the map level. This below style should put an icon on all Point features in the future version of gl-draw. In the current version you'd need to name the layer to overwrite the point layer which also means your LineString and Polygon handles would be this icon. {
"id": "coffee-shops",
"type": "symbol",
"filter": ["all",
["==", "$type", "Point"],
["==", "meta", "feature"]],
"layout": {
"icon-image": "icon_name"
},
"interactive": true
} |
2065d25 to
aee0f6e
Compare
|
@mcwhittemore very cool stuff. A few things I noticed:
|
I don't currently have a Assuming we had a getter that returned the user provided feature the mode is currently focused on you still wouldn't be able to preform
👍
Yea. I don't think Draw should be in this game. If the apis for this aren't good for mapbox-gl-js we should fix it there or create a small module that makes this easy.
Agree. There isn't an event for feature changes. Maybe we can solve these two problems with one event? |
src/setup.js
Outdated
| let style = theme[i]; | ||
| style.source = 'draw-selected'; | ||
| // TODO: this should be on both sources... | ||
| // TODO: let users overwrite this... |
There was a problem hiding this comment.
@mcwhittemore are you going to hit this on this PR?
There was a problem hiding this comment.
Yea. The overwrite should be really simple and having a hot and cold source should help with performance.
src/api.js
Outdated
| var featureTypes = { | ||
| "Polygon": require('./feature_types/polygon'), | ||
| "LineString": require('./feature_types/line_string'), | ||
| "Point": require('./feature_types/point') |
|
@mcwhittemore this could really use a linting pass |
|
Just a few bugs
|
|
901350c to
1800a37
Compare
| benchmark.on('fail', function(event) { | ||
| log('red', '<strong class="prose-big">' + event.message + '</strong>'); | ||
| scrollToBottom(); | ||
| }); |
There was a problem hiding this comment.
What does it mean for a benchmark to "pass" or "fail"? I encourage you to think about benchmark scores as something we work to improve over time rather than something that passes or fails.
615528f to
6435a20
Compare
Closes #257
Closes #249 - selection is not longer a global concept in Draw so forcing feature to be selected is no longer viable.
Closes #247
Closes #245 - draw.changed is emitted with ever render
Closes #243
Closes #218 - draw.changed is emitted with ever render. Adding vertices causes a render.
Closes #128 - fixed in [email protected]
Closes #109 - permanent features have been removed
This PR is moving us away from a tool where features describe how events affect them to a system where modes describe how they effect features. Currently you can draw a feature, select a feature and change a features coordinates at almost any time. This is communicated to the end-user via two styles (selected and unselected). Moving forward each of these actions will be available via different modes and only one mode will be running at a time.
Overview of modes
Below is a list of the current modes and what they can do. I also need to document what styling options this gives the end-developer both in CSS and the map style.
The draw modes are always available via the draw controls or via
api.startDrawingI think all modes should be enterable via the api.
Features Select
Direct Selectby doubling clicking on a featureDirect Select
Features Selectby double clicking any whereDraw LineString
Lets you draw a LineString. Exits to
Features SelectDraw Polygon
Lets you draw a Polygon. Exits to
Features SelectDraw Point
Lets you place a point. Exits to
Features SelectNotes
This is still a long way out
The goals of this PR are: