目前我正在使用像优步iOS应用程序的应用程序.我已经集成了Google Maps SDK,我也为用户当前位置显示了自定义图像.目前我从服务器获得了一些Driver的当前位置详细信息(例如:100个驱动程序).我保存在一个中NSArray
,我尝试使用以下代码在GoogleMaps上显示Lat&Long:
for(int i=0;i<[latLongArr count];i++) { GMSMarker *marker = [[GMSMarker alloc] init]; marker.position = CLLocationCoordinate2DMake([[(NSDictionary *)[latLongArr objectAtIndex:i] valueForKey:@"Latitude"] doubleValue], [[(NSDictionary *)[latLongArr objectAtIndex:i] valueForKey:@"Longitude"] doubleValue]); marker.appearAnimation = kGMSMarkerAnimationPop; marker.title = @"Title"; marker.snippet = @"Sub title"; marker.map = self.gMapView; }
但我正在寻找像这样的UIDesign和功能:
可以任何人帮助我如何显示用户当前位置和驱动程序的注释列表
(如何在谷歌地图上旋转自定义标记图像)
在方向API(苹果或谷歌地图)有一个列表点.因此,要计算两点之间的角度,您可以:
func DegreeBearing(A:CLLocation,B:CLLocation)-> Double{ var dlon = self.ToRad(B.coordinate.longitude - A.coordinate.longitude) let dPhi = log(tan(self.ToRad(B.coordinate.latitude) / 2 + M_PI / 4) / tan(self.ToRad(A.coordinate.latitude) / 2 + M_PI / 4)) if abs(dlon) > M_PI{ dlon = (dlon > 0) ? (dlon - 2*M_PI) : (2*M_PI + dlon) } return self.ToBearing(atan2(dlon, dPhi)) } func ToRad(degrees:Double) -> Double{ return degrees*(M_PI/180) } func ToBearing(radians:Double)-> Double{ return (ToDegrees(radians) + 360) % 360 } func ToDegrees(radians:Double)->Double{ return radians * 180 / M_PI }
并为制造商设置轮换
maker.rotation = DegreeBearing(self.fromPoint, B: self.toPoint)
下面更新了ObjC代码
-(double) DegreeBearing:(CLLocation*) A locationB: (CLLocation*)B{ double dlon = [self ToRad:(B.coordinate.longitude - A.coordinate.longitude)]; double dPhi = log(tan([self ToRad:(B.coordinate.latitude)] / 2 + M_PI / 4) / tan([self ToRad:(A.coordinate.latitude)] / 2 + M_PI / 4)); if (fabs(dlon) > M_PI){ dlon = (dlon > 0) ? (dlon - 2*M_PI) : (2*M_PI + dlon); } return [self ToBearing:(atan2(dlon, dPhi))]; } -(double) ToRad: (double)degrees{ return degrees*(M_PI/180); } -(double) ToBearing:(double)radians{ double degree = [self ToDegrees:radians]; return degree+360% 360; } -(double) ToDegrees:(double)radians{ return radians * 180 / M_PI; }