mapbox / mapbox/mapbox-gl-draw
Error when try to move vertex of a multi features in direct_select mode.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 612
- Avg merge
- 8d 9h
- Merged PRs (30d)
- 5
Description
The cause of the error is that during the drag operation MultiFeature calls the takeAction function for every element in its feature array:
MultiFeature.prototype.updateCoordinate = function(path, lng, lat) {
takeAction(this.features, 'updateCoordinate', path, lng, lat);
this.changed();
};
These elements in the feature array are not directly included in the main Source. Therefore MultiFeature calls updateCoordinate of all internal features, and these will call the Store.featureChanged method with an featureId parameter that is not in Store of context of MapboxDraw.
Polygon.prototype.updateCoordinate = function(path, lng, lat) {
this.changed();
...
}
This causes that bad id entered into the _changedFeatureIds object, and then the
this.get(featureId).toGeoJSON()
throws error becuse get method returns undefined.
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
Start with MultiFeature.prototype.updateCoordinate and trace its calls into Polygon.prototype.updateCoordinate and Store.featureChanged. Reproduce dragging a multi-feature in direct_select mode, then inspect _changedFeatureIds and the get(featureId).toGeoJSON() call. Done means the drag no longer records internal feature IDs that are absent from the Store or throws this error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100