swift 3谷歌地图 - 如何在地图上更新标记

时间:2017-06-30 13:37:26

标签: ios google-maps swift3 xcode8

我正在使用谷歌地图

这是我的代码:

import UIKit
import GoogleMaps

 class ViewController: UIViewController {

@IBAction func pressed(_ sender: Any) {

    //self.myMapView.marker.position = CLLocationCoordinate2D(latitude: +31.75097956, longitude: +35.23694378)

}




@IBOutlet weak var myMapView: GMSMapView!


override func viewDidLoad() {
    super.viewDidLoad()


    let camera = GMSCameraPosition.camera(withLatitude: +31.75097946, longitude: +35.23694368, zoom: 17.0)
    self.myMapView.mapType =  .terrain
    self.myMapView.camera = camera
    // Creates a marker in the center of the map.
    let marker = GMSMarker()
    marker.position = CLLocationCoordinate2D(latitude: +31.75097946, longitude: +35.23694368)
    marker.title = "some text"
    marker.map = self.myMapView
    marker.opacity = 1.0

}

有一个UIView加载地图。还有一个按钮 按下按钮时,我想更新标记的位置。

感谢

1 个答案:

答案 0 :(得分:2)

创建.git/config作为类变量。按钮单击功能添加以下代码

marker
相关问题