0
我基本上實現了一個功能,其中在用戶移動地圖後出現一個按鈕,並且當選擇該按鈕時,在可見區域中發生新的搜索。問題是可見區域不準確,所以當我嘗試再次放大時,它會縮小。在iOS上的谷歌地圖上設置位置
每當我點擊按鈕時,下面的函數被調用,地圖縮小。據我所知,沒有要求animate
和刪除代碼將避免變焦,但我想知道爲什麼變焦正在發生的事情,因爲這可能會導致問題的其他地方
@IBAction func updateSearchSelected(sender: UIButton) {
let northEast = CLLocationCoordinate2D(latitude: mapView!.projection.visibleRegion().farRight.latitude, longitude: mapView!.projection.visibleRegion().farRight.longitude)
let southWest = CLLocationCoordinate2D(latitude: mapView!.projection.visibleRegion().nearLeft.latitude, longitude: mapView!.projection.visibleRegion().nearLeft.longitude)
print("northEast \(northEast)")
print("southWest \(southWest)")
let coordinateBounds = GMSCoordinateBounds(coordinate: northEast, coordinate: southWest)
let cameraUpdate = GMSCameraUpdate.fit(coordinateBounds)
mapView?.animate(with: cameraUpdate)
}
這裏是點擊按鈕3次
後的日誌northEast CLLocationCoordinate2D(latitude: 37.84227633765466, longitude: -122.38477706909181)
southWest CLLocationCoordinate2D(latitude: 37.674750313908689, longitude: -122.50391006469727)
northEast CLLocationCoordinate2D(latitude: 37.859492217765393, longitude: -122.37251903861761)
southWest CLLocationCoordinate2D(latitude: 37.657491381296779, longitude: -122.51616809517145)
northEast CLLocationCoordinate2D(latitude: 37.880245733530728, longitude: -122.35773839056492)
southWest CLLocationCoordinate2D(latitude: 37.636675535472314, longitude: -122.53094874322414)
這不起作用我想因爲我不知道縮放級別,我知道邊界,API返回邊界,我需要正確顯示邊界 – aryaxt
因此,只需決定任意縮放級別,並將其保持在該縮放級別,以便在更新時不會縮小。 –
如果它需要顯示整個內容,它不應該縮放: – aryaxt