我正在使用Google地圖SDK for ios。我想在屏幕中心固定一個標記,所以當用戶拖動地圖時,標記不會移動並停留在中心。我也試圖在拖動之後讀取中心的座標。任何輸入將不勝感激。謝謝!谷歌地圖上的ios固定標記
4
A
回答
3
1
在地圖的中心創建GMSMapView中的出口和連接的圖像和在頂部搜索欄呈現位置名稱。
在Device上拖動地圖,這會觸發GMSMapViewDelegate的2委託方法。
func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition)
func mapView(_ mapView: GMSMapView, idleAt position: GMSCameraPosition)
/** * Called repeatedly during any animations or gestures on the map (or once, if the camera is * explicitly set). This may not be called for all intermediate camera positions. It is always * called for the final position of an animation or gesture. */ func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) { print("didchange")> > returnPostionOfMapView(mapView: mapView) } /** * Called when the map becomes idle, after any outstanding gestures or animations have completed (or * after the camera has been explicitly set). */ func mapView(_ mapView: GMSMapView, idleAt position: GMSCameraPosition) { print("idleAt") //called when the map is idle returnPostionOfMapView(mapView: mapView) } //Convert the location position to address func returnPostionOfMapView(mapView:GMSMapView){ let geocoder = GMSGeocoder() let latitute = mapView.camera.target.latitude let longitude = mapView.camera.target.longitude let position = CLLocationCoordinate2DMake(latitute, longitude) geocoder.reverseGeocodeCoordinate(position) { response , error in if error != nil { print("GMSReverseGeocode Error: \(String(describing: error?.localizedDescription))") }else { let result = response?.results()?.first let address = result?.lines?.reduce("") { $0 == "" ? $1 : $0 + ", " + $1 } self.searchBar.text = address } } }
相關問題
- 1. 谷歌地圖上的固定標記
- 2. IOS谷歌地圖自定義標記
- 3. Objectivec固定標記谷歌地圖中心ios
- 4. 在谷歌地圖上閃爍的自定義標記iOS
- 5. 自定義谷歌地圖標記圖標圖像在swift ios
- 6. 谷歌地圖iOS標記不刪除
- 7. 如何固定谷歌地圖上的iOS?
- 8. 谷歌地圖上的標記問題
- 9. 谷歌地圖V3上的SVG標記
- 10. 適合谷歌地圖上的標記
- 11. 谷歌地圖上的標記
- 12. 谷歌地圖上的標記
- 13. 更新谷歌地圖上的標記
- 14. 谷歌地圖上的GPS標記android
- 15. 谷歌地圖上的設置標記
- 16. 從谷歌地圖中刪除固定標記
- 17. 谷歌地圖 - 多標記
- 18. 標記在谷歌地圖
- 19. RxJS谷歌地圖標記
- 20. 谷歌地圖標記
- 21. 谷歌地圖標記url
- 22. 谷歌地圖 - 多標記
- 23. 谷歌地圖API標記
- 24. android谷歌地圖標記
- 25. 谷歌地圖標記infowindow
- 26. 谷歌地圖標記DROP
- 27. 谷歌地圖:getSelected標記
- 28. 到標記谷歌地圖
- 29. 谷歌地圖標記
- 30. 谷歌地圖xml標記
感謝彼得。我很難在GMSMapView之上顯示視圖。我嘗試使用'insertSubview'和'addSubview',但只要設置'self.view = _mapView;',標記視圖就不會顯示在最上面。 – Yini