Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

MGLPolygon, MGLPolyline coordinates should be mutable #6160

Closed
1ec5 opened this issue Aug 25, 2016 · 6 comments
Closed

MGLPolygon, MGLPolyline coordinates should be mutable #6160

1ec5 opened this issue Aug 25, 2016 · 6 comments
Assignees
Labels
annotations Annotations on iOS and macOS or markers on Android beta blocker Blocks the next beta release feature iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS
Milestone

Comments

@1ec5
Copy link
Contributor

1ec5 commented Aug 25, 2016

Just as it’s very convenient to be able to change an MGLPointAnnotation’s coordinate property and have the annotation move on the fly, it should be possible to change the shape of an MGLPolygon or MGLPolyline. This would be useful for GPS and fitness tracking applications as well as applications that allow the user to trace features over the map.

MGLMultiPoint has a coordinates property that – due to Objective-C language limitations – holds a C array of CLLocationCoordinate2Ds, rather than an NSArray that we’d easily be able to make mutable. Nonetheless, we could pair this property with one that holds an NSMutableArray of NSValues representing CLLocationCoordinate2Ds, then implement all the to-many getters and setters expected by KVO. Alternatively, we could add a -setCoordinates:range: method. Either approach will be somewhat messy in Objective-C and even messier when bridged to Swift.

This is the iOS/macOS equivalent of #5224 on Android. I consider this feature blocked by #5844. The awkwardness of the API we’d add would outweigh any benefits to implementing a stopgap API like in #5848 on Android.

/cc @incanus @pveugen

@1ec5 1ec5 added feature iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS annotations Annotations on iOS and macOS or markers on Android labels Aug 25, 2016
@pveugen pveugen added this to the ios-future milestone Aug 26, 2016
@boundsj
Copy link
Contributor

boundsj commented Aug 29, 2016

Noting that #6185 landed that fixed #5844

@ryanbaumann
Copy link

@1ec5 What's an expected timeline on draggable/mutable points on iOS, now that #5844 is no longer a blocker?

@incanus
Copy link
Contributor

incanus commented Oct 3, 2016

@ryanbaumann Currently scoping this out. Draggable is a different, higher-level issue and would likely be as equally complex as the mutation part, but could also be implemented in a custom way by any SDK users.

@incanus
Copy link
Contributor

incanus commented Oct 3, 2016

This looks to be fairly straightforward—messy proof of concept done, which continually updates an MGLPolyline to connect (45, -122) and the map center upon map movement:

foo

Did this by way of a temporary -[MGLMapView updateAnnotation:withAnnotation:] which takes MGLPolyline arguments.

The right way to do this is KVO in MGLMapView like how we do for point coordinates, but that uses the same core stuff under the hood (_mbglMap->updateAnnotation()) as this proof of concept, which proves this will be performant and look 👌.

Stay tuned—should finish this completely today or tomorrow.

@incanus incanus modified the milestones: ios-v3.4.0, ios-future Oct 3, 2016
@incanus incanus added the beta blocker Blocks the next beta release label Oct 3, 2016
@incanus incanus self-assigned this Oct 3, 2016
@incanus
Copy link
Contributor

incanus commented Oct 3, 2016

This feels good for shapes, too.

bar

@incanus
Copy link
Contributor

incanus commented Oct 3, 2016

PR for this ready for review in #6565.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
annotations Annotations on iOS and macOS or markers on Android beta blocker Blocks the next beta release feature iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS
Projects
None yet
Development

No branches or pull requests

5 participants