【发布时间】:2018-03-28 19:06:52
【问题描述】:
在我移动地图中的图钉后,我正在尝试获取坐标。我使用了用户当前位置,当我打开地图时正确显示。但是当我将图钉移到另一条街道时,将无法让新坐标仍然显示相同的坐标。
这是我的代码
var Map = require('ti.map');
if(Ti.Geolocation.locationServicesEnabled){
Ti.Geolocation.addEventListener('location', function(e) {
if (e.error){
alert('Error: ' + e.error);
}else {
longitude = e.coords.longitude;
latitude = e.coords.latitude;
var mapView = Map.createView({
top : 0,
left : 0,
bottom : 0,
right : 0,
mapType : Map.STANDARD_TYPE,
animate : true,
regionFit : true,
userLocation : false,
touchEnabled : true,
draggable : true
});
view3.add(mapView);
view3.add(boton2);
var annotation = Map.createAnnotation({
latitude : latitude,
longitude : longitude,
title : 'Selecciona Tu Ubicación',
draggable : true
});
mapView.setAnnotations([annotation]);
var region = {
latitude : latitude,
longitude : longitude,
animate : true,
latitudeDelta : 0.005,
longitudeDelta : 0.005
};
mapView.setRegion(region);
mapView.addEventListener('pinchangedragstate', function(e) {
Ti.API.info(longitude + ' - ' + latitude);
});
}
});
}else{
alert('Por favor habilita los servicios de ubicación');
}
谢谢!
【问题讨论】:
标签: javascript maps titanium coordinates appcelerator