【问题标题】:Custom marker view not showing in swift google maps快速谷歌地图中未显示自定义标记视图
【发布时间】:2015-02-04 07:49:12
【问题描述】:

我想在我的地图上显示自定义标记视图。 我的参考来自:https://stackoverflow.com/a/16767124/2849443

var pin:GMSMarker = GMSMarker(position: CLLocationCoordinate2DMake(currentLocation.coordinate.latitude, currentLocation.coordinate.longitude))
pin.infoWindowAnchor = CGPointMake(0.0, 0.0)
pin.icon = UIImage(named: "img_map_pin")
pin.map = mapView?
mapView?.selectedMarker = pin

我的自定义视图标记方法如下所示

func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! {
    var arr:NSArray = NSBundle.mainBundle().loadNibNamed("MarkerView", owner: self, options: nil)
    var view:MarkerView = arr[0] as MarkerView
    view.IBlblAddress?.text = "text"
    return view
}

我已经设置了委托 GMSMapViewDelegate 和 mapView.delegate = self is set ,但我的方法仍然没有被调用。可能是什么问题?

【问题讨论】:

    标签: ios google-maps swift


    【解决方案1】:
    var marker = GMSMarker()
        marker.position = CLLocationCoordinate2DMake(41.887, -87.622)//here you can give your current lat and long
        marker.appearAnimation = kGMSMarkerAnimationPop
        marker.icon = UIImage(named: "flag_icon")
        marker.map = mapView
    
        self.view = mapView
    

    https://developers.google.com/maps/documentation/ios/

    【讨论】:

    • @Pooja Shah 上面的答案对你有帮助吗?更新给别人很重要。
    • 是的,一旦你启动了你的标记,那么你必须将标记的地图设置为你创建的 mapView。
    猜你喜欢
    • 1970-01-01
    • 2018-10-07
    • 2014-07-18
    • 2012-09-05
    • 1970-01-01
    • 2014-05-17
    • 1970-01-01
    • 1970-01-01
    • 2013-08-21
    相关资源
    最近更新 更多