我想用 ionic 构建移动应用程序,首先用户是地理定位的我想每 2 秒更新一次他的位置这是地理定位的代码
$scope.makeFit = function() {
leafletData.getMap().then(function(map) {
map.locate({setView: true, maxZoom: 16});
var marker;
function onLocationFound(e) {
marker= new L.Marker(e.latlng);
marker.addTo(map)
.bindPopup("" + e.latlng + " ");
}
map.on('locationfound', onLocationFound);
});
};
最佳答案
请read the Leaflet reference documentation ,它记录了 locate()
的 watch
选项,它将执行此操作。
关于leaflet - 实时地理定位 ionic ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24411537/