GeolocationCoordinates: toJSON() ã¡ã½ãã
Baseline
2024
Newly available
Since September 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
toJSON() 㯠GeolocationCoordinates ã¤ã³ã¿ã¼ãã§ã¤ã¹ã®ã¡ã½ããã§ãã·ãªã¢ã©ã¤ã¶ã¼ã§ããããã¯ãã® GeolocationCoordinates ãªãã¸ã§ã¯ãã® JSON 表ç¾ãè¿ãã¾ãã
æ§æ
toJSON()
弿°
ãªãã
è¿å¤
JSON ãªãã¸ã§ã¯ãã§ãããã® GeolocationCoordinates ãªãã¸ã§ã¯ããã·ãªã¢ã©ã¤ãºãããã®ã§ãã
ä¾
>toJSON() ã¡ã½ããã®ä½¿ç¨
ãã®ä¾ã§ã¯ãposition.coords.toJSON() ãå¼ã³åºãã¨ããã® GeolocationCoordinates ãªãã¸ã§ã¯ãã® JSON 表ç¾ãè¿ãã¾ãã
navigator.geolocation.getCurrentPosition((position) => {
console.log(position.coords.toJSON());
});
ããã¯æ¬¡ã®ãã㪠JSON ãªãã¸ã§ã¯ãããã°åºåãã¾ãã
{
"accuracy": 12.0,
"latitude": 53.0,
"longitude": 8.0,
"altitude": null,
"altitudeAccuracy": null,
"heading": null,
"speed": null
}
JSON æååãåå¾ããã«ã¯ãJSON.stringify(position.coords) ãç´æ¥å¼ã³åºãã¦ãã ããããã㯠toJSON() ãèªåçã«å¼ã³åºãã¾ãã
仿§æ¸
| Specification |
|---|
| Geolocation > # tojson-method-0 > |