對於在項目中使用的GPS可以用以下
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function (position) {
// Did we get the position correctly?
// alert (position.coords.latitude);
// To see everything available in the position.coords array:
// for (key in position.coords) {alert(key)}
mapServiceProvider(position.coords.latitude,position.coords.longitude);
},
// next function is the error callback
function (error)
{
switch(error.code)
{
case error.TIMEOUT:
alert ('Timeout');
break;
case error.POSITION_UNAVAILABLE:
alert ('Position unavailable');
break;
case error.PERMISSION_DENIED:
alert ('Permission denied');
break;
case error.UNKNOWN_ERROR:
alert ('Unknown error');
break;
}
});
}
的代碼,可以發現here或phonegap docs 當你有,你可以改變你的 形式值的位置。那麼是否使用谷歌地圖插件 的問題。我個人並沒有使用任何。由於 您正在使用jQuery手機,您可以使用this。
創建在init事件地圖(所以你只創建一次),並 觸發在pageshow事件resize事件,所以你不會有問題 與地圖出現在你的屏幕等 的左上角如果您使用我提到的插件,請查找刷新方法。 地圖的容器必須具有大小。如果不是, 將無法正常顯示,因爲jqm會將最小尺寸 添加到容器中。您可以通過編程(檢查窗口高度和寬度)來計算空間(如果存在 標題,則必須將其包含在計算中)。 最後,如果您有在this
感謝您的詳細回答變焦看問題。 – farjam
如果這回答了你的問題,你爲什麼不接受它? http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235 – alkis