Ios 如何在地图应用程序(苹果地图或谷歌地图)上显示带有特定角度信息的地标?
我想在地图应用程序上显示枪声信息。枪声有两个主要特性:Ios 如何在地图应用程序(苹果地图或谷歌地图)上显示带有特定角度信息的地标?,ios,objective-c,gps,maps,mapkit,Ios,Objective C,Gps,Maps,Mapkit,我想在地图应用程序上显示枪声信息。枪声有两个主要特性: 位置-发射子弹的点 方向/角度-相对于指南针北 使用以下代码片段,我可以打开带有特定位置标记的“地图”应用程序 CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(gps_lat.doubleValue, gps_long.doubleValue); MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoord
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(gps_lat.doubleValue, gps_long.doubleValue);
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate addressDictionary:nil];
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
[mapItem setName:self.pUnit.unitLabel];
[mapItem openInMapsWithLaunchOptions:nil];
是否可以将角度/方向信息与位置标记一起添加?基本上,位置标记应随地图旋转,以便清楚地描绘枪声的方向
- 您可以使用谷歌地图和标记的旋转属性实现标记的旋转
- 虽然您需要obj-c代码,但我的swift代码将有助于您理解我的意思
- 用您的图像替换标记\图像\名称
let camera = GMSCameraPosition.camera(withLatitude: firstPoint.latitude,
longitude: firstPoint.longitude, zoom: 14)
let navHeight = (self.navigationController?.navigationBar.frame.size.height)! + 20
let frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height - navHeight)
let GMapView = GMSMapView.map(withFrame: frame, camera: camera)
self.view.addSubview(GMapView)
marker.map = GMapView
2) 准备标记
let bearing:Double = 90
var marker = GMSMarker()
marker.icon = UIImage(named: MARKER_IMAGE_NAME)
marker.appearAnimation = GMSMarkerAnimation.pop
3) 应用旋转
marker.rotation = bearing
4) 添加标记到谷歌地图
let camera = GMSCameraPosition.camera(withLatitude: firstPoint.latitude,
longitude: firstPoint.longitude, zoom: 14)
let navHeight = (self.navigationController?.navigationBar.frame.size.height)! + 20
let frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height - navHeight)
let GMapView = GMSMapView.map(withFrame: frame, camera: camera)
self.view.addSubview(GMapView)
marker.map = GMapView
我希望它由地图应用程序处理,而不是作为我的应用程序中的子视图。