Mobile 如何利用传单实时提取用户的经纬度
Mobile 如何利用传单实时提取用户的经纬度,mobile,geolocation,leaflet,latitude-longitude,Mobile,Geolocation,Leaflet,Latitude Longitude,我正在跨平台移动应用程序中使用传单。 我希望用户能够实时看到他/她的移动 我还想将它们的经度和纬度分别作为全局变量保存,因为我需要这些信息,以便稍后进行计算 以下是我目前的情况: map.locate({ watchPosition:true, maxZoom:16 }); function onLocationFound(e) { var radius = e.accuracy / 2; L.circle(e.l
我正在跨平台移动应用程序中使用传单。
我希望用户能够实时看到他/她的移动
我还想将它们的经度和纬度分别作为全局变量保存,因为我需要这些信息,以便稍后进行计算
以下是我目前的情况:
map.locate({
watchPosition:true,
maxZoom:16
});
function onLocationFound(e)
{
var radius = e.accuracy / 2;
L.circle(e.latlng, radius,
{
color: 'red',
fillColor: '#f03',
fillOpacity: 0.5,
radius: 400
}).addTo(map);
}
map.on('locationfound', onLocationFound);
我相信“watchPosition:true”可以让地图持续监视用户。
我就是不知道如何提取经纬度信息。
提前感谢传单
地图。查找
选项仅限于:
如果true
,则使用W3CwatchPosition
方法开始连续监视位置变化(而不是检测一次)
function onLocationFound(e)
{
var radius = e.accuracy / 2;
userLat = e.latlng.lat;
userLng = e.latlng.lng;
movingCircle.setLatLng(e.latlng);
movingCircle.redraw();
}
var userLocation = map.locate
({
watch:true,
maxZoom:16,
enableHighAccuracy: true
});
var userLat;
var userLng;
enter code here
var movingCircle = L.circle([0,0], 20,
{color: 'red',
fillColor: '#f03',
fillOpacity: 0.5,
draggable: true }).addTo(map);