|
var map = api.require('bMap');
var lat='39.989539';
var lon='116.384767';
map.open({
center: {
lon: lon,
lat: lat
}
}, function(ret) {
if (ret.status) {
showToast("打开成功!");
map.getLocation({
accuracy: '100m',
autoStop: true,
filter: 1
}, function(ret, err){
alert(JSON.stringify(ret));
if(ret.status){
lat = ret.lat;
lon = ret.lon;
//设置地图中心
map.setCenter({
coords: {
lon: ret.lon,
lat: ret.lat
},
animation:false
});
//根据坐标获取位置
getNameFromCoords();
}else{
showToast('网络异常'+err.code);
}
});
}
}); |
|