|
@@ -72,17 +72,18 @@ var bootstrap = function ($, learun) { |
|
|
} else { |
|
|
} else { |
|
|
initMap() |
|
|
initMap() |
|
|
} |
|
|
} |
|
|
function initMap() { |
|
|
|
|
|
var currentPoint = $('#GPSLon').val() && $('#GPSLat').val() ? { lng: $('#GPSLon').val(), lat: $('#GPSLat').val()} : {}, //经纬度 {lng,lat} |
|
|
|
|
|
|
|
|
async function initMap() { |
|
|
|
|
|
let defaultPoint = await local() |
|
|
|
|
|
var currentPoint = $('#GPSLon').val() && $('#GPSLat').val() ? { lng: $('#GPSLon').val(), lat: $('#GPSLat').val() } : defaultPoint, //经纬度 {lng,lat} |
|
|
radius = $('#GPSRange').val() || 20, //打卡距离(m) |
|
|
radius = $('#GPSRange').val() || 20, //打卡距离(m) |
|
|
map = new BMapGL.Map("container", { |
|
|
map = new BMapGL.Map("container", { |
|
|
enableRotate: false, |
|
|
|
|
|
enableTilt: false, |
|
|
|
|
|
|
|
|
//enableRotate: false, |
|
|
|
|
|
//enableTilt: false, |
|
|
}), // 创建地图实例 |
|
|
}), // 创建地图实例 |
|
|
point = $('#GPSLon').val() && $('#GPSLat').val() ? new BMapGL.Point($('#GPSLon').val(), $('#GPSLat').val()) : new BMapGL.Point(116.404, 39.915); // 创建点坐标 |
|
|
|
|
|
|
|
|
point = $('#GPSLon').val() && $('#GPSLat').val() ? new BMapGL.Point($('#GPSLon').val(), $('#GPSLat').val()) : defaultPoint; // 创建点坐标 |
|
|
|
|
|
|
|
|
map.centerAndZoom(point, 17); // 初始化地图,设置中心点坐标和地图级别 |
|
|
map.centerAndZoom(point, 17); // 初始化地图,设置中心点坐标和地图级别 |
|
|
//map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放 |
|
|
|
|
|
|
|
|
map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放 |
|
|
// map.setHeading(64.5); //设置地图旋转角度 |
|
|
// map.setHeading(64.5); //设置地图旋转角度 |
|
|
// map.setTilt(73); //设置地图的倾斜角度 |
|
|
// map.setTilt(73); //设置地图的倾斜角度 |
|
|
|
|
|
|
|
@@ -151,7 +152,7 @@ var bootstrap = function ($, learun) { |
|
|
function myFun() { |
|
|
function myFun() { |
|
|
currentPoint = local.getResults().getPoi(0).point; //获取第一个智能搜索的结果 |
|
|
currentPoint = local.getResults().getPoi(0).point; //获取第一个智能搜索的结果 |
|
|
setPointVal(currentPoint) |
|
|
setPointVal(currentPoint) |
|
|
map.centerAndZoom(currentPoint, 18); |
|
|
|
|
|
|
|
|
map.centerAndZoom(currentPoint, 17); |
|
|
map.addOverlay(new BMapGL.Marker(currentPoint)); //添加标注 |
|
|
map.addOverlay(new BMapGL.Marker(currentPoint)); //添加标注 |
|
|
setCircle(currentPoint)//设置圆 |
|
|
setCircle(currentPoint)//设置圆 |
|
|
} |
|
|
} |
|
@@ -207,6 +208,22 @@ var bootstrap = function ($, learun) { |
|
|
$('#GPSLat').val(point.lat.toFixed(8)) |
|
|
$('#GPSLat').val(point.lat.toFixed(8)) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前位置 |
|
|
|
|
|
function local() { |
|
|
|
|
|
return new Promise((resolve) => { |
|
|
|
|
|
// 创建定位对象 |
|
|
|
|
|
let geolocation = new BMapGL.Geolocation(); |
|
|
|
|
|
geolocation.getCurrentPosition(async function (r) { |
|
|
|
|
|
if (this.getStatus() == BMAP_STATUS_SUCCESS) { |
|
|
|
|
|
resolve(r.point) |
|
|
|
|
|
} else { |
|
|
|
|
|
resolve(new BMapGL.Point(116.404, 39.915))//北京 |
|
|
|
|
|
} |
|
|
|
|
|
}, { enableHighAccuracy: true }); |
|
|
|
|
|
navigator.geolocation.clearWatch(geolocation); |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//有数据时候添加覆盖物 |
|
|
//有数据时候添加覆盖物 |
|
|
if ($('#GPSLon').val() && $('#GPSLat').val()) { |
|
|
if ($('#GPSLon').val() && $('#GPSLat').val()) { |
|
|