mapbox / mapbox/mapbox-gl-draw
Custom mode documentation excludes key information regarding 'active' and 'inactive' states of drawn features
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 612
- Avg merge
- 8d 9h
- Merged PRs (30d)
- 5
Description
I've just lot quite a bit of time for something that could be better explained within the Custom Mode documentation.
I've created a custom mode for drawing nodes and lines, and I wanted the "active" styling that is used in the pre-determined modes to be usable as well.
The documentation mentions that using `this.select` will control which features are selected, which does work _internally_, but does not control the 'active' state on the drawn features. I had to dig through the un-minified MapDraw file to discover that the 'active' state is actually to be controlled manually within the `toDisplayFeatures`, like so:
```
DrawLineMode.toDisplayFeatures = function(state, geojson, display) {
geojson.properties.active = !!this.isSelected(geojson.properties.id) + '';
display(geojson);
};
```
It's a simple bit of code obviously, however the documentation could do with a note that the `active` property in the drawn GeoJSON is to be manually controlled within the custom mode, and isn't actually related to the `selected` states.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the Custom Mode documentation and review its sections on this.select, selected features, and toDisplayFeatures; use the un-minified MapDraw file and the DrawLineMode.toDisplayFeatures entry point as references. Done means the documentation clearly distinguishes selected state from the GeoJSON active property and explains the manual active-state handling with the example shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100