@@ -125,6 +125,8 @@ public class MapboxBridge: NSObject {
125125 private var imageRegistry : [ String : UIImage ] = [ : ]
126126 private var viewAnnotationByMarkerId : [ String : ViewAnnotation ] = [ : ]
127127
128+ private var defaultPinImageHeight : CGFloat = 0
129+
128130 // Camera handling
129131 private var cameraIdleWorkItem : DispatchWorkItem ?
130132 private var cameraChangeCallback : ( ( [ String : Any ] ) -> Void ) ? = nil
@@ -201,8 +203,11 @@ public class MapboxBridge: NSObject {
201203
202204 // Register this bridge for the created MapView
203205 MapboxBridge . registerBridge ( self , for: mv)
204-
205- addImage ( " default_pin " , UIImage ( named: " default_pin " ) )
206+ let defaultPinImage = UIImage ( named: " default_pin " )
207+ if ( defaultPinImage != nil ) {
208+ self . defaultPinImageHeight = defaultPinImage!. size. height
209+ addImage ( " default_pin " , defaultPinImage)
210+ }
206211
207212 if let options = optionsOpt {
208213 if ( ( options [ " hideLogo " ] as? Bool ) == true ) {
@@ -456,7 +461,7 @@ public class MapboxBridge: NSObject {
456461 else { theId = String ( NSDate ( ) . timeIntervalSince1970) }
457462 }
458463 var pa = PointAnnotation ( id: theId! , coordinate: CLLocationCoordinate2D ( latitude: lat, longitude: lng) )
459-
464+ pa . iconAnchor = . bottom
460465 // userInfo
461466 var userInfo = JSONObject ( )
462467
@@ -544,8 +549,8 @@ public class MapboxBridge: NSObject {
544549 annotation. allowOverlap = true
545550 annotation. allowOverlapWithPuck = true
546551 let image = an. image
547- let imageHeight = image? . image. size. height ?? 0
548- let offsetY = imageHeight/ 2 + 5
552+ let imageHeight = image? . image. size. height ?? self . defaultPinImageHeight
553+ let offsetY = imageHeight + 5
549554 // TODO: variableAnchors is broken for now if multiple
550555 annotation. variableAnchors = [ ViewAnnotationAnchorConfig ( anchor: . bottom, offsetY: offsetY)
551556 // , ViewAnnotationAnchorConfig(anchor: .bottomLeft, offsetY: offsetY), ViewAnnotationAnchorConfig(anchor: .bottomRight, offsetY: offsetY)
0 commit comments