Skip to content

Instantly share code, notes, and snippets.

@ohtwo
Last active October 27, 2020 01:19
Show Gist options
  • Save ohtwo/f3d149c670cc12cfea4642c2750514df to your computer and use it in GitHub Desktop.
Save ohtwo/f3d149c670cc12cfea4642c2750514df to your computer and use it in GitHub Desktop.
GMSMarker with Drop Shadow
import Foundation
import GoogleMaps
func getShadowMarker() -> GMSMarker {
let marker = GMSMarker()
let image = UIImageView(image: UIImage(named: "marker"))
marker.iconView = image
marker.iconView?.contentMode = .center
marker.iconView?.bounds.size.width *= 2
marker.iconView?.bounds.size.height *= 2
marker.groundAnchor = CGPoint(x: 0.5, y: 0.75)
marker.iconView?.layer.shadowColor = UIColor.black.cgColor
marker.iconView?.layer.shadowOffset = CGSize.zero
marker.iconView?.layer.shadowRadius = 1.0
marker.iconView?.layer.shadowOpacity = 0.5
let size = image.bounds.size
let rect = CGRect(x: size.width/2 - size.width/8, y: size.height*0.75 - 2, width: size.width/4, height: 4)
marker.iconView?.layer.shadowPath = UIBezierPath(ovalIn: rect).cgPath
marker.appearAnimation = .pop
marker.position = kCLLocationCoordinate2DInvalid
return marker
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment