簡體   English   中英

在 iconView 的幫助下,在 ios swift 中的谷歌 map 上沒有繪制多個標記

[英]with help of iconView , multiple marker are not ploted on google map in ios swift

I am plotting multiple custom-view marker on google map in iOS swift project but some time they are not plot but when I tap on google map tappable action is call. 表示數據可用,但某些標記未繪制或不可見。

我正在使用下面的代碼

for oldSites in self.marrPlotedMarker {
let position = CLLocationCoordinate2D(latitude: tempSite["lat"].double ?? 0, longitude: tempSite["lon"].double ?? 0)
let marker = GMSMarker()
    marker.tracksViewChanges = false
marker.iconView = mycustoumview()
marker.position = position
//marker.isFlat = true
marker.map = self.myMapview

}
}

您的代碼片段並沒有描繪出整個畫面,但我猜您需要在創建標記之前將self.myMapView添加為子視圖:

所以你的代碼看起來像這樣:

self.addSubview(self.myMapView) // important piece
for oldSites in self.marrPlotedMarker {
    let position = CLLocationCoordinate2D(latitude: tempSite["lat"].double ?? 0, longitude: tempSite["lon"].double ?? 0)
    let marker = GMSMarker()
    marker.tracksViewChanges = false
    marker.iconView = mycustoumview()
    marker.position = position
    //marker.isFlat = true
    marker.map = self.myMapview
}

請參閱此帖子以獲取類似的問題/答案: 在 Google 地圖中放置多個標記。 Swift

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM