2016-05-24 15 views
1

私はGMaps SDK for Swiftを使用しています。私の目標は脈動効果のようなアニメーションタイプの標準マーカーを置き換えることです。私は層で遊んだが運がなかった。どのように私のマーカー画像にアニメーション効果を追加することができますか?Google Maps Swiftの脈動マーカーアニメーション

let parkingSpotsPosition = CLLocationCoordinate2D(latitude: self.SpotLocationLatitudes.last!, longitude: self.SpotLocationLongitudes.last!) 
        let marker = GMSMarker(position: parkingSpotsPosition) 
        marker.title = self.SpotNames.last 
        //marker.icon = GMSMarker.markerImageWithColor(UIColor.greenColor()) 
        marker.icon = UIImage(named: "parking-location") 
        marker.map = self.gMapsView 
+0

が重複する可能性:// stackoverflowの.com/questions/18529248/how-set-custom-annotation-marker-animated-rings-around-a-point-on-gmsmapview –

+0

本当ですが、問題はまだ存在しています –

答えて

0

イメージはその状態で描画できます。例えば、アラームを脈動させるアラームは、1つのラインが点灯し、2つのラインが点灯するなどで描画されます。次に、それらの画像をアニメートします。

はそうのようなanimatedImage、個々の画像、及び画像の配列を定義します。
var animatedImage: UIImage! 
var image1: UIImage! 
var image2: UIImage! 
var image3: UIImage! 
var image4: UIImage! 
var images: [UIImage]! 

は、どこかのviewDidLoadのように、あなたが選んだの期間でそれを設定します。個々の画像を描画するためにSketch Appを使用します。

image1 = UIImage(named: "MarkerTrouble1.png") 
image2 = UIImage(named: "MarkerTrouble2.png") 
image3 = UIImage(named: "MarkerTrouble3.png") 
image4 = UIImage(named: "MarkerTrouble4.png") 

images = [image1, image2, image3, image4] 

animatedImage = UIImage.animatedImage(with: images, duration: 0.8) 

あなたはいつもGMSMapViewとGMSMarkerコードを使用し、その後、地図上のアニメーション画像を描画し、脈動効果を見たいと思って、何かのように:HTTPの

let marker = GMSMarker() 
let markerView = UIImageView(image: animatedImage) 
marker.position = CLLocationCoordinate2D(latitude: userLat, longitude: userLng) 
marker.iconView = markerView 
marker.map = mapView