我正在尝试创建一个显示Google地图的简单页面,以当前位置为中心。
我已经能够成功获得以下的lat / long,从那里我也将它存储在localStorage中。 :
var geooptions = {timeout: 10000, maximumAge: 11000, enableHighAccuracy: true };
var geofail = function(){
alert("Geolocation failed. \nPlease enable GPS in Settings.");
};
var geosuc = function(p){
localStorage.lat = p.coords.latitude;
localStorage.lon = p.coords.longitude;
localStorage.latlon = p.coords.latitude + ', ' + p.coords.longitude;
};
var getLocation = intel.xdk.geolocation.watchPosition(geosuc,geofail,geooptions);
var stopGeolocation = function(){
intel.xdk.geolocation.clearWatch(geolocationWatchTimer);
}
当我尝试用这个绘制地图时,没有任何反应 - 我有一个div =" page_4":
function drawMap() {
//Creates a new google maps object
var latlng = new google.maps.LatLng(localStorage.lat, localStorage.lon);
myLatLng = latlng;
var mapOptions = {
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL,
position: google.maps.ControlPosition.LEFT_TOP
},
};
var mymap = new google.maps.Map(document.getElementById("page_4"), mapOptions);
}
答案 0 :(得分:0)
发现问题,在任何XDK示例中都不明确/显而易见,但您显然仍需要包含Google地图API脚本...