これは私が書いた関数の一部です
watchlocation: function() {
console.log("watchlocation Started");
if (watchProcess == null) {
watchProcess = navigator.geolocation.watchPosition(locationcheck.handle_geolocation_query_success, locationcheck.handle_errors, {enableHighAccuracy:true});
}
if(position.coords.latitude == null) {
var Lat = '52.5960';
console.log("latitude Set Manually");
}
else {
var Lat = position.coords.latitude;
console.log("latitude Set Automatically");
};
if(position.coords.longitude == null) {
var lon = '-1.9110';
console.log("longitude Set Manually");
}
else {
var lon = position.coords.longitude;
console.log("longitude Set Automatically");
};
locationcheck.handle_geolocation_query_successalt(position.coords.latitude,position.coords.longitude);
console.log("watchlocation Position Passed");
},
position.coords.latitudeまたはposition.coords.longitudeコンソールにアクセスしようとするたびに、
'Uncaught Type Error:Can not read property' latitude'of undefined'&'Uncaught Type Error:Can not read property' longitude'of undefined
私がここでやろうとしていることの最終結果は、HTLM5標準を介して現在の場所を取得することです。それが機能しない場合は、緯度経度のグローバル変数に置き換えてください。
これまでアラートボックスの一部としてposition.coords.latitude、position.coords.longitudeにアクセスできたので、私はまだ物事を行うための最良の方法を学んでいるので、おそらくここでの私の方法にかかっていると思います。
TIA
テラン
JörnBerkefeldsのコメントを編集して、私はvar postion = ""; それ以外の場合はどこが正しかったか-私はそれを削除し、それは問題を解決しました。
T