GMSMarker icon from center (iOS)

前端 未结 3 1054
不思量自难忘°
不思量自难忘° 2020-12-29 02:35

I just switched from Apple Maps to Google Maps. An issue that I can\'t seem to find an answer to is how do you make the icon for a GMSMarker to start from the center rather

3条回答
  •  难免孤独
    2020-12-29 03:21

    In Swift 5

        let marker: GMSMarker = GMSMarker() // Allocating Marker
        marker.title = "Your location" // Setting title
        marker.snippet = "Sub title" // Setting sub title
        marker.icon = UIImage(named: "radio") // Marker icon
        marker.appearAnimation = .pop // Appearing animation. default
        marker.position = CLLocationCoordinate2D.init(latitude: 26.8289443, longitude: 75.8056178)
        
        marker.groundAnchor = CGPoint(x: 0.5, y: 0.5)  // this is the answer of this question
                
        DispatchQueue.main.async { // Setting marker on mapview in main thread.
            marker.map = self.googleMapView // Setting marker on Mapview
        }
    

提交回复
热议问题