ons.navigator.pushPage を使用して searchNearby html ページに移動すると、現在の位置情報座標が表示されます。しかし、それはしません。searchNearby ページを直接読み込むと、座標が完全に表示されます。それについての任意のアイデア
index.html
<body ng-controller="courseController">
<ons-navigator title="Class Finder">
<ons-page>
<ons-row>
<ons-col size="80" style="padding: 8px">
<ons-search-input ng-model="searchText" placeholder="Search..." >
</ons-search-input>
</ons-col>
<ons-col size="20" >
<ons-button type="large--quiet" ng-click="ons.navigator.pushPage('searchNearby/index.html',{title:'Search Nearby'})">Search nearby
</ons-button>
</ons-col>
</ons-row>
</ons-page>
</ons-navigator>
</body>
searchNearby/index.html
<body>
<p id="geolocation">Finding geolocation...</p>
<div id="t01"> </div>
<script type="text/javascript" charset="utf-8">
var lat,lon;
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
function onSuccess(position) {
var element = document.getElementById('geolocation');
element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' +
'Longitude: ' + position.coords.longitude + '<br />' +
'Altitude: ' + position.coords.altitude + '<br />' +
'Accuracy: ' + position.coords.accuracy + '<br />' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '<br />' +
'Heading: ' + position.coords.heading + '<br />' +
'Speed: ' + position.coords.speed + '<br />' +
'Timestamp: ' + position.timestamp + '<br />';
}
function onError(error){
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
</script>
</body>