我正在尝试使用 IndoorAtlas SDK 构建一个用于室内导航的小示例。我正在使用谷歌地图而不是苹果 map 。 从 IndoorAtlas 后端获取平面图图像后,我需要创建 GMSCoordinateBounds,它需要 SouthWest 和 NorthEast 坐标来创建边界。我需要知道如何正确确定这些坐标。 目前我的代码看起来像这样:
CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(self.floorPlan.topRight.latitude,self.floorPlan.topRight.longitude);
CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(self.floorPlan.bottomLeft.latitude,self.floorPlan.bottomLeft.longitude);
GMSCoordinateBounds *overlayBounds = [[GMSCoordinateBounds alloc] initWithCoordinate:southWest coordinate:northEast];
UIImage *icon = fpImage;
GMSGroundOverlay *overlay =
[GMSGroundOverlay groundOverlayWithBounds:overlayBounds icon:icon];
overlay.bearing = self.floorPlan.bearing;
overlay.map = _mapView;
GMSCameraUpdate *updatedCamera = [GMSCameraUpdate setTarget:self.floorPlan.center zoom:10];
[self.mapView animateWithCameraUpdate:updatedCamera];
self.marker.position = self.camera.target;
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:self.camera];
如何确定上述坐标。尝试上述坐标我没有得到正确的矩形。
还有其他方法可以确定吗?
最佳答案
我找到了一种计算坐标的方法
-(NSArray *)calculateLongLatDegreesInMeters:(CLLocationDegrees)纬度 {
float lat = M_PI * latitude / 180;
// Constants for calculating lengths
float m1 = 111132.92;
float m2 = -559.82;
float m3 = 1.175;
float m4 = -0.0023;
float p1 = 111412.84;
float p2 = -93.5;
float p3 = 0.118;
float eq1 = m1 + (m2 * cos(2 * lat)) + (m3 * cos(4 * lat));
float latitudeDegreeInMeters = eq1 + (m4 * cos(6 * lat));
float longitudeDegreeInMeters = (p1 * cos(lat)) + (p2 * cos(3 * lat)) + (p3 * cos(5 * lat));
NSString *latDegInMtr = [NSString stringWithFormat:@"%f",latitudeDegreeInMeters];
NSString *lonDegInMtr = [NSString stringWithFormat:@"%f",longitudeDegreeInMeters];
NSArray *arr = [NSArray arrayWithObjects:latDegInMtr,lonDegInMtr, nil];
return arr; //(latitudeDegreeInMeters, longitudeDegreeInMeters)
关于ios - 确定 Indoor Atlas 平面图图像的西南和东北,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39446397/