gpt4 book ai didi

ios - 如何使用 swift 在谷歌地图上显示自定义图像

转载 作者:可可西里 更新时间:2023-11-01 01:19:08 25 4
gpt4 key购买 nike

如何显示 these kind of car images in picture在谷歌地图上根据经纬度?

我尝试了以下代码,but I got the following incorrect result

 let marker1 = GMSMarker()
let marker2 = GMSMarker()
let marker3 = GMSMarker()
let marker4 = GMSMarker()
let marker5 = GMSMarker()
let markerImage = UIImage(named: "white_car_icon copy.png")!.withRenderingMode(.alwaysTemplate)

let markerView = UIImageView(image: markerImage)
marker1.position = CLLocationCoordinate2D(latitude: 12.9077923, longitude: 77.586962)
marker2.position = CLLocationCoordinate2D(latitude: 12.9077923, longitude: 77.586962)
marker3.position = CLLocationCoordinate2D(latitude: 12.9077856, longitude: 77.58695950000001)
marker4.position = CLLocationCoordinate2D(latitude: 12.90782858, longitude: 77.58678956)
marker5.position = CLLocationCoordinate2D(latitude: 12.90780888511306, longitude: 77.58487723767757)
marker1.iconView = markerView
marker1.map = mapView
marker2.iconView = markerView
marker2.map = mapView
marker3.iconView = markerView
marker3.map = mapView
marker4.iconView = markerView
marker4.map = mapView
marker5.iconView = markerView
marker5.map = mapView

如果有人能帮我解决这个问题,我将不胜感激。过去 4 天我一直在尝试,但没有得到正确的输出。

最佳答案

正确的选择是使用图标属性

 marker5.icon = UIImage(named: "paradero")

有了这个你可以设置任何你想要的图像。

关于ios - 如何使用 swift 在谷歌地图上显示自定义图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44726012/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com