0

phonegap ビルドでユーザーの位置を追跡するマップを表示しようとしています。この例を使用しようとしていますが、

http://view.jquerymobile.com/master/demos/map-geolocation/

そして、html cssとjsをアプリに追加して追加しました

<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="http://api.phonegap.com/1.0/network"/> 

私のconfig.xmlファイルに。

何もロードされていない白い画面しか表示されません。

私は何を間違っていますか!?!?

みんなありがとう!皆さんは過去に私をとても助けてくれました。これは私がこのアプリを完成させるために必要な最後のことです!

よろしくお願いします!

私が使用する私のhtmlコードは

<div role="main" class="ui-content" id="map-canvas"></div>

私が使用する私のCSSコードは

#map-page, #map-canvas { width: 100%; height: 100%; padding: 0; } 

私が使用する私のjsコードは

<script>
$( document ).on( "pageinit", "#map-page", function() {
var defaultLatLng = new google.maps.LatLng(34.0983425, -118.3267434); // Default to        Hollywood, CA when no geolocation support
if ( navigator.geolocation ) {
function success(pos) {
// Location found, show map with these coordinates
drawMap(new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude));
}
function fail(error) {
drawMap(defaultLatLng); // Failed to find location, show default map
}
// Find the users current position. Cache the location for 5 minutes, timeout after 6     seconds
navigator.geolocation.getCurrentPosition(success, fail, {maximumAge: 500000,      enableHighAccuracy:true, timeout: 6000});
} else {
drawMap(defaultLatLng); // No geolocation support, show default map
}
function drawMap(latlng) {
var myOptions = {
zoom: 10,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
// Add an overlay to the map of current lat/lng
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: "Greetings!"
});
}
});
</script> 

そして、私は js を html の直前、直後に配置しています

<div data-role="content" class="content">

しかし、私も頭の中に入れてみました。

4

2 に答える 2

1

geo コールの前に、緯度と経度の変数を 0 に設定してみてください。

  document.addEventListener("deviceready", onDeviceReady, false);
  function onDeviceReady() { 
    navigator.geolocation.getCurrentPosition(onSuccess, onError, { maximumAge:60000, timeout:5000, enableHighAccuracy:true }); 
  }

  var lat = 0;
  var lng = 0;

  function onSuccess(position) {
    lat += position.coords.latitude
    lng += position.coords.longitude
  }
于 2015-01-18T18:21:51.820 に答える