Firefox 13 で地理位置情報オブジェクトを JSON 文字列に変換しようとしていますが、JSON オブジェクトの正しい文字列表現ではなく、空の文字列が返されます。これは、最新バージョンの Chrome と Safari、および Android ブラウザーで正常に動作します。これが私のコードです:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function (position) {
//Success handler
console.log(position); //This outputs the position object to the console
var gps = JSON.stringify(position);
console.log(gps); //This outputs an empty string!
},
function (error)
{
//Handle error
},
{ maximumAge: 3000, timeout: 60000, enableHighAccuracy: true }
);
}
else {
//Handle error
}
Chrome では、位置情報オブジェクトと次の文字列が出力されます。
"{"coords":{"latitude":XYZ,"heading":null,"accuracy":40,"altitudeAccuracy":null,"altitude":null,"longitude":XYZ,"speed":null},"timestamp":1339712284200}"
ただし、Firefox 13 では、コンソールに出力される地理位置情報オブジェクトが、Chrome によって表示されるオブジェクトとすべての意図と目的が同じであっても、出力は単なる空の文字列です。ここで何がうまくいかないのかについてのアイデアはありますか? これは関連する問題のようですが、そこにも解決策はありません。ちなみに、IE9でも同じ動作が表示されます。