tobyapp
tobyapp

Reputation: 189

Ambiguous use of 'kGMSMarkerAnimationPop' Error in Swift 2

Im having an error while trying to animate a GMSMarker, I have followed the Google documentation and various guides but it keeps returning an error, below is my code:

func placeMarker(coordinate: CLLocationCoordinate2D) {
    if locationMarker != nil {
        locationMarker.map = nil
    }

    locationMarker = GMSMarker(position: coordinate)
    locationMarker.icon = GMSMarker.markerImageWithColor(purple)
    locationMarker.appearAnimation = kGMSMarkerAnimationPop
    locationMarker.snippet = "The best place on earth."
    locationMarker.map = mapView
}

Which returns the error Ambiguous use of 'kGMSMarkerAnimationPop'

Any help would be appriciated!

Upvotes: 3

Views: 2852

Answers (5)

Sajjad Parmar
Sajjad Parmar

Reputation: 9

Swift 3
marker.appearAnimation = kGMSMarkerAnimationpop

Swift 4

marker.appearAnimation = GMSMarkerAnimation.pop

Upvotes: 0

GraSim
GraSim

Reputation: 4220

In Swift 3/GoogleMaps 2.3.0. The new syntax is :

marker.appearAnimation = GMSMarkerAnimation.pop

Upvotes: 4

Ujjwal Madan
Ujjwal Madan

Reputation: 21

I looked around and I found an answer that worked for me:

locationMarker.appearAnimation = GoogleMaps.kGMSMarkerAnimationPop

Upvotes: 2

Howard Liu
Howard Liu

Reputation: 189

upgrading google map pod won't work, at least until 1.12.3.

  1. change GMSMarkerAnimation in GMSMarker.h from this:

    typedef enum {
      /** No animation (default). */
      kGMSMarkerAnimationNone = 0,
    
      /** The marker will pop from its groundAnchor when added. */
      kGMSMarkerAnimationPop,
    } GMSMarkerAnimation;
    

    to this:

    typedef NS_ENUM(NSInteger, GMSMarkerAnimation){
      /** No animation (default). */
      kGMSMarkerAnimationNone = 0,
    
      /** The marker will pop from its groundAnchor when added. */
      kGMSMarkerAnimationPop,
    } ;
    
  2. change

    locationMarker.appearAnimation = kGMSMarkerAnimationPop

    to

    locationMarker.appearAnimation = GMSMarkerAnimation.Pop

Upvotes: 6

yonasstephen
yonasstephen

Reputation: 2725

For me this happens when I upgrade from GoogleMap 1.10.3 to 1.11.1 using CocoaPod. Previously using 1.10.3 it requires me to import all of the header files of GoogleMap in Bridging-Header.h file.

To remove this ambiguous error, I just commented out all the imported headers in Bridging-Header.h

Upvotes: 3

Related Questions