我想在地图上显示自定义标记视图。 我从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,但仍然没有调用我的方法。可能是什么问题?
答案 0 :(得分:0)
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