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

标签 ios google-maps google-maps-sdk-ios

我在 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/

相关文章:

带有标记动画信息框的 Android 谷歌地图

ios - 放大屏幕中央 - Google Maps iOS SDK Swift

iOS:电子书的大量交互式文本

javascript - 从javascript/html播放音频时设置自定义元数据(Control Center iOS)

ios - 使用 scrollViewWillEndDragging 自定义 UIScrollView 分页

ios - 解析和其他 Facebook 权限 (iOS)

javascript - 创建 map 后向 Google map v3 添加标记

javascript - 如何更改容器 div 的高度以适合所有动态内容?

ios - 如何在谷歌地图 iOS 上放置一个文本字段

ios - func didTapAt 坐标没有显示任何东西