gpt4 book ai didi

ios - 如何为谷歌地图 IOS 设置可见区域/缩放级别以显示添加到 map View 的所有标记

转载 作者:可可西里 更新时间:2023-11-01 04:41:53 26 4
gpt4 key购买 nike

我在 iOS 应用程序中使用过 Google map ,我想根据我在 map 上进行的搜索动态设置缩放级别。基本上是通过搜索城市名称或纬度/经度查询来添加图钉。每次搜索后我都会添加图钉,我需要通过最近的搜索显示所有添加的标记。

最佳答案

@IBOutlet weak var mapView: GMSMapView!

let camera = GMSCameraPosition.cameraWithLatitude(23.0793, longitude:
72.4957, zoom: 5)
mapView.camera = camera
mapView.delegate = self
mapView.myLocationEnabled = true

*** arry has dictionary object which has value of Latitude and Longitude. ***
let path = GMSMutablePath()

for i in 0..<arry.count {

let dict = arry[i] as! [String:AnyObject]
let latTemp = dict["latitude"] as! Double
let longTemp = dict["longitude"] as! Double

let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: latTemp, longitude: longTemp)
marker.title = "Austrilia"
marker.appearAnimation = kGMSMarkerAnimationNone
marker.map = self.mapView

path.addCoordinate(CLLocationCoordinate2DMake(latTemp, longTemp))

}

let bounds = GMSCoordinateBounds(path: path)
self.mapView!.animateWithCameraUpdate(GMSCameraUpdate.fitBounds(bounds, withPadding: 50.0))

关于ios - 如何为谷歌地图 IOS 设置可见区域/缩放级别以显示添加到 map View 的所有标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19514957/

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