In the project development, the vehicle uses the Baidu map to preach the GPS coordinates, the web uses the gold map, the problem comes: in the IOS10 version above, the German positioning API call failed. Instead of Baidu map can be replaced by Baidu map, so long need for coordinate conversion, online find the conversion method
JavaScript implementation of geo-coordinate system and correlative algorithm of electronic map
The following direct code:
Mars coordinates convert to Baidu map coordinates
function Bd_encrypt (Gg_lon, Gg_lat) {
var x_pi = Math.PI * 3000.0/180.0;
var x = Gg_lon, y = Gg_lat;
var z = math.sqrt (x * x + y * y) + 0.00002 * Math.sin (y * x_pi);
var theta = math.atan2 (y, x) + 0.000003 * MATH.COS (x * x_pi);
var Bd_lon = z * Math.Cos (theta) + 0.0065;
var Bd_lat = z * Math.sin (theta) + 0.006;
return {
Bd_lat:bd_lat,
Bd_lon:bd_lon
};
}
Baidu map coordinates converted to Mars coordinates
JS Code Collection Code
function Bd_decrypt (Bd_lon,bd_lat) {
var x_pi = Math.PI * 3000.0/180.0;
var x = bd_lon-0.0065;
var y = bd_lat-0.006;
var z = math.sqrt (x * x + y * y)-0.00002 * Math.sin (y * x_pi);
var theta = math.atan2 (y, x)-0.000003 * MATH.COS (x * x_pi);
var Gg_lon = z * Math.Cos (theta);
var Gg_lat = z * Math.sin (theta);
return {
Gg_lon:gg_lon,
Gg_lat:gg_lat
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.