大佬教程收集整理的这篇文章主要介绍了ios – Google地图缩小到GPS和标记,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
self.startMarker.position = CL@R_801_5352@nCoordinate2D(latitude: self.startLatitude,longitude: self.startLongitudE) self.startMarker.icon = #imageLiteral(resourcename: "Pin Start") self.startMarker.map = self.mapView self.endMarker.position = CL@R_801_5352@nCoordinate2D(latitude: self.endLatitude,longitude: self.endLongitudE) self.endMarker.icon = #imageLiteral(resourcename: "Pin End") self.endMarker.map = self.mapView let southWest = CL@R_801_5352@nCoordinate2DMake(self.startLatitude,self.startLongitudE) let northEast = CL@R_801_5352@nCoordinate2DMake(self.endLatitude,self.endLongitudE) let bounds = GMSCoordinateBounds(coordinate: northEast,coordinate: southWest) let camera = self.mapView.camera(for: bounds,insets:.zero) self.mapView.camera = camera!
更多代码:
// MARK: - Google Map private func @R_801_5352@nManager(manager: CL@R_801_5352@nManager,didChangeAuthorizationStatus status: CLAuthorizationStatus) { if status == CLAuthorizationStatus.authorizedWhenInUse { mapView.isMy@R_801_5352@nEnabled = true } } func @R_801_5352@nManager(_ manager: CL@R_801_5352@nManager,didupdate@R_801_5352@ns @R_801_5352@ns: [CL@R_801_5352@n]) { let new@R_801_5352@n = @R_801_5352@ns.last mapView.camera = GMSCameraPosition.camera(withTarget: new@R_801_5352@n!.coordinate,zoom: 14) mapView.isMy@R_801_5352@nEnabled = true }
结果是这样的:
我需要的 :
@L_607_4@
EDITED
if let my@R_801_5352@n = self.mapView.my@R_801_5352@n { let path = GMSMutablePath() path.add(my@R_801_5352@n.coordinatE) path.add(self.startMarker.position) path.add(self.endMarker.position) let bounds = GMSCoordinateBounds(path: path) self.mapView.animate(with: GMSCameraupdate.fit(bounds,withPadding: 40))
}
在这里我试图给你一个简单的例子,希望这将有助于你.
使用此功能,您可以在屏幕上显示任意数量的标记.
let path = GMSMutablePath() for var i in 0 ..< array.count { let lat = Double(array.objectATindex(i).valueForKey(lattitudE) as! String) let long = Double(arrayr.objectATindex(i).valueForKey(longitudE) as! String) marker.position = CL@R_801_5352@nCoordinate2DMake(lat!,long!) path.addCoordinate(marker.position) marker.map = self.mapView } let bounds = GMSCoordinateBounds(path: path) self.mapView!.animateWithCameraupdate(GMSCameraupdate.fitBounds(bounds,withPadding: 30.0))
以上是大佬教程为你收集整理的ios – Google地图缩小到GPS和标记全部内容,希望文章能够帮你解决ios – Google地图缩小到GPS和标记所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。