腾讯地图转换微信
function cyberwin_qqMapTransBMap(long, lat) {
? let cyber_pi = 3.14159265358979324 * 3000.0 / 180.0;
? let org_ong = long;
? let org_lat = lat;
? let cyber_rate = Math.sqrt(org_ong * org_ong + org_lat * org_lat) + 0.00002 * Math.sin(org_lat * cyber_pi);
? let theta = Math.atan2(org_lat, org_ong) + 0.000003 * Math.cos(org_ong * cyber_pi);
? let lngs = cyber_rate * Math.cos(theta) + 0.0065;
? let lats = cyber_rate * Math.sin(theta) + 0.006;
? return {
? ? lng: lngs,
? ? lat: lats
? };
}
小程序调用百度地图错误示范
wx.openLocation({
longitude: lng,
latitude: lat,
name: name,
address: address,
scale:scale
});
正确示范
var longlattrand = cybewin_BMapTransqqMap(lng,lat);
console.log(longlattrand);
lng=longlattrand.lng;
lat==longlattrand.lat;
wx.openLocation({
longitude: lng,
latitude: lat,
name: name,
address: address,
scale:scale
});
下面是百度地图转换小程序地图
function cyberwin_BMapTransqqMap(lng, lat) {
? let cyber_pi = 3.14159265358979324 * 3000.0 / 180.0;
? let org_long = lng - 0.0065;
? let org_lat = lat - 0.006;
? let cyber_rate = Math.sqrt(org_long * org_long + org_lat * org_lat) + 0.00002 * Math.sin(org_lat * cyber_pi);
? let theta = Math.atan2(org_lat, org_long) + 0.000003 * Math.cos(org_long * cyber_pi);
? let lngs = cyber_rate * Math.cos(theta);
? let lats = cyber_rate * Math.sin(theta);
? return {
? ? lng: lngs,
? ? lat: lats
? };
}
|