GMSMarker自定义图标不会根据坐标显示。 iOS - Swift - 谷歌地图

时间:2018-06-17 15:20:45

标签: ios swift google-maps gmsmapview

我是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

0 个答案:

没有答案