Coordinate Conversion between Baidu navigation SDK and iOS navigation sdk
Examples of code for converting coordinates of Baidu navigation iOS SDK. For more information, see.
// Navigation coordinate --------------> map coordinate
// Assume that the coordinate obtained from the navigation sdk is (116.304847, 40.025281)
// (1) construct the input parameter BNPosition required by the Conversion Function
BNPosition * naviPos = [[BNPosition alloc] init];
NaviPos. x = 116.304847;
NaviPos. y = 40.025281;
// Define output parameters
BMapPoint mapPoint = {0, 0 };
// Call the Conversion Function
BOOL ret = [BNTools ConvertBaiduNaviPoint: naviPos ToBaiduMapPoint: & mapPoint];
// Use the converted map coordinates
If (ret)
{
NSLog (@ "the navigation coordinates are converted into map coordinates. After the conversion, MapPoint = (% f, % f)", mapPoint. x, mapPoint. y );
}
Else
{
NSLog (@ "Conversion failed ");
}
// Navigation coordinate --------------> map coordinate
// Assume that the coordinate obtained from the navigation sdk is (116.304847, 40.025281)
// (1) construct the input parameter BNPosition required by the Conversion Function
BNPosition * naviPos = [[BNPosition alloc] init];
NaviPos. x = 116.304847;
NaviPos. y = 40.025281;
// Define output parameters
BMapPoint mapPoint = {0, 0 };
// Call the Conversion Function
BOOL ret = [BNTools ConvertBaiduNaviPoint: naviPos ToBaiduMapPoint: & mapPoint];
// Use the converted map coordinates
If (ret)
{
NSLog (@ "the navigation coordinates are converted into map coordinates. After the conversion, MapPoint = (% f, % f)", mapPoint. x, mapPoint. y );
}
Else
{
NSLog (@ "Conversion failed ");
}