我是iOS平台的新手,将自定义图标(车辆图标)添加到GMSMarker,但它没有根据坐标显示在地图视图上,甚至以蓝色显示而不是原始图像颜色。
请检查以下代码:
func ambulanceOnMap() {
let vehicle = UIImage(named: "mapAmbulance")!.withRenderingMode(.alwaysTemplate)
let markerView = UIImageView(image: vehicle)
vehicleImage = markerView
let position = CLLocationCoordinate2D(latitude: 24.9259594, longitude: 67.0844429)
let marker = GMSMarker(position: position)
marker.iconView = markerView
marker.tracksViewChanges = true
marker.map = mapView
vehicleMarker = marker
}
//Emergency Button Tapped
@objc func buttonAction(sender: UIButton!) {
ambulanceOnMap()
vehicleImage.frame = CGRect(x: 0, y: 0, width: 100, height: 50)
self.view.addSubview(self.vehicleImage)
}
结果截图附: Result Screenshot