-
-
Notifications
You must be signed in to change notification settings - Fork 852
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iOS V10 PointAnnotation Drag and Selection Support (#2077)
* Feature: migrateOfflineCache - Added the migrate function for iOS and Android from the official Mapbox 'Migrate to v10' guides * iOS V10 PointAnnotation Build Out - Added draggable support for PointAnnotation - Added support for onDrag, onDragEnd, onDragStart, onDeselected, and onSelected * Update android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLOfflineModule.kt Co-authored-by: Miklós Fazekas <[email protected]> * Update android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLOfflineModule.kt Co-authored-by: Miklós Fazekas <[email protected]> * RCTMGLInteractiveComponent - Created new subclass RCTMGLInteractiveComponent that extracts commonality between RCTMGLSource and RCTMGLPointAnnotation * Renamed RCTMGLInteractiveComponent to RCTMGLInteractiveElement * Remove extra migrateOfflineCache method * Feature: migrateOfflineCache - Added the migrate function for iOS and Android from the official Mapbox 'Migrate to v10' guides * iOS V10 PointAnnotation Build Out - Added draggable support for PointAnnotation - Added support for onDrag, onDragEnd, onDragStart, onDeselected, and onSelected * Update android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLOfflineModule.kt Co-authored-by: Miklós Fazekas <[email protected]> * Update android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLOfflineModule.kt Co-authored-by: Miklós Fazekas <[email protected]> * RCTMGLInteractiveComponent - Created new subclass RCTMGLInteractiveComponent that extracts commonality between RCTMGLSource and RCTMGLPointAnnotation * Renamed RCTMGLInteractiveComponent to RCTMGLInteractiveElement * Remove extra migrateOfflineCache method * Remove extra isDraggable function from RCTMGLSource Co-authored-by: Miklós Fazekas <[email protected]>
- Loading branch information
Showing
5 changed files
with
327 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
@_spi(Experimental) import MapboxMaps | ||
|
||
@objc | ||
class RCTMGLInteractiveElement : UIView, RCTMGLMapComponent { | ||
|
||
var map : RCTMGLMapView? = nil | ||
|
||
var layers: [RCTMGLSourceConsumer] = [] | ||
|
||
static let hitboxDefault = 44.0 | ||
|
||
@objc var draggable: Bool = false | ||
|
||
@objc var hasPressListener: Bool = false | ||
|
||
@objc var hitbox : [String:NSNumber] = [ | ||
"width": NSNumber(value: hitboxDefault), | ||
"height": NSNumber(value: hitboxDefault) | ||
] | ||
|
||
@objc var id: String! = nil | ||
|
||
@objc var onDragStart: RCTBubblingEventBlock? = nil | ||
|
||
@objc var onPress: RCTBubblingEventBlock? = nil | ||
|
||
func getLayerIDs() -> [String] { | ||
layers.compactMap { | ||
if let layer = $0 as? RCTMGLLayer { | ||
return layer.id | ||
} else { | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
func isDraggable() -> Bool { | ||
return draggable | ||
} | ||
|
||
func isTouchable() -> Bool { | ||
return hasPressListener | ||
} | ||
|
||
// MARK: - RCTMGLMapComponent | ||
func addToMap(_ map: RCTMGLMapView, style: Style) { | ||
self.map = map | ||
} | ||
|
||
func removeFromMap(_ map: RCTMGLMapView) { | ||
self.map = nil | ||
} | ||
|
||
func waitForStyleLoad() -> Bool { | ||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.