我有一個web應用程序,它在Web視圖中顯示網頁。但網頁無法拿起getcurrentposition,但是如果我在android broswer中顯示它的網頁,但不是在web應用程序中?Android Web應用程序無法啓動GPS
當頁從一個Web應用程序運行時顯示該頁面的地圖顯示有 它會在下面的JS的「這裏」警報和 「錯誤:地理定位服務失敗。」
有沒有人寫過本地的網絡應用程序,可以拿起地理位置? java web應用程序或許可中必須有其他必需的東西。有沒有人做到了這一點..
這裏是我想要使用谷歌例如HTML,
http://code.google.com/apis/maps/documentation/javascript/examples/map-geolocation.html 這裏是JS
var initialLocation;
var siberia = new google.maps.LatLng(60, 105);
var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
var browserSupportFlag = new Boolean();
var map;
var infowindow = new google.maps.InfoWindow();
function initialize() {
var myOptions = {
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
// Try W3C Geolocation method (Preferred)
if (navigator.geolocation) {
browserSupportFlag = true;
alert('here navigator');
navigator.geolocation.getCurrentPosition(function (position) {
initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
contentString = "Location found using W3C standard";
map.setCenter(initialLocation);
infowindow.setContent(contentString);
infowindow.setPosition(initialLocation);
infowindow.open(map);
}, function() {
handleNoGeolocation(browserSupportFlag);
});
} else if (google.gears) {
// Try Google Gears Geolocation
browserSupportFlag = true;
var geo = google.gears.factory.create('beta.geolocation');
geo.getCurrentPosition(function (position) {
initialLocation = new google.maps.LatLng(position.latitude, position.longitude);
contentString = "Location found using Google Gears";
map.setCenter(initialLocation);
infowindow.setContent(contentString);
infowindow.setPosition(initialLocation);
infowindow.open(map);
}, function() {
handleNoGeolocation(browserSupportFlag);
});
} else {
// Browser doesn't support Geolocation
browserSupportFlag = false;
handleNoGeolocation(browserSupportFlag);
}
}
function handleNoGeolocation(errorFlag) {
if (errorFlag == true) {
initialLocation = newyork;
contentString = "Error: The Geolocation service failed.";
} else {
initialLocation = siberia;
contentString = "Error: Your browser doesn't support geolocation. Are you in Siberia?";
}
map.setCenter(initialLocation);
infowindow.setContent(contentString);
infowindow.setPosition(initialLocation);
infowindow.open(map);
}
任何想法.. 感謝邁克
你想做什麼?我從來沒有聽說過原生的網絡應用程序。我假定你的意思是你製作了一個Android應用程序,只顯示你的網頁應用程序的頁面? – 2011-04-11 13:34:22
是的,你是正確的一個Android應用程序,顯示一個網站地理位置.. – ozmike 2011-07-05 13:40:37