// 百度地图经纬度转腾讯地图经纬度
function qqMapTransBMap(lng, lat) {
let x_pi = Math.PI * 3000.0 / 180.0;
let x = lng;
let y = lat;
let z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
let theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
let lngs = z * Math.cos(theta) + 0.0065;
let lats = z * Math.sin(theta) + 0.006;
return {
lng: lngs,
lat: lats
}
}
//
腾讯地图经纬度转百度地图经纬度
function bMapTransQQMap(lng, lat) {
let x_pi = Math.PI * 3000.0 / 180.0;
let x = lng - 0.0065;
let y = lat - 0.006;
let z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
let theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
let lngs = z * Math.cos(theta);
let lats = z * Math.sin(theta);
return {
lng: lngs,
lat: lats
}
}
// 腾讯地图将所有的marker显示在地图视野内容
var bounds = new TMap.LatLngBounds();
markerArr.forEach(function(item){
//若坐标点不在范围内,扩大bounds范围
if(bounds.isEmpty() || !bounds.contains(item.position)){
bounds.extend(item.position);
}
})
//设置地图可视范围
map.fitBounds(bounds, {
padding: 100 // 自适应边距
});