HTMLGeolocationElement: error ããããã£
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
error 㯠HTMLGeolocationElement ã¤ã³ã¿ã¼ãã§ã¤ã¹ã®èªã¿åãå°ç¨ããããã£ã§ãä½ç½®ãã¼ã¿ã®åå¾ã«å¤±æããå ´åã«ãã¨ã©ã¼æ
å ±ã表ã GeolocationPositionError ãªãã¸ã§ã¯ããè¿ãã¾ãã
ä½ç½®ãã¼ã¿ã®åå¾ãæåããå ´åããã®ãã¼ã¿ã¯ HTMLGeolocationElement.position ããããã£ã§å©ç¨å¯è½ã§ãã
å¤
GeolocationPositionError ã§ããä½ç½®ãã¼ã¿ã®åå¾ã«æåããå ´å㯠null ã§ãã
ä¾
>åºæ¬çãªä½¿ãæ¹
html
<geolocation autolocate></geolocation>
js
const geo = document.querySelector("geolocation");
geo.addEventListener("location", () => {
if (geo.position) {
console.log(
`(${geo.position.coords.latitude},${geo.position.coords.longitude})`,
);
} else if (geo.error) {
console.log(geo.error.message);
}
});
error ãå«ãå®éã®ä¾ã«ã¤ãã¦ã¯ãçµã¿è¾¼ã¿å°å³ã®ä¾ã®æé ã追ã£ã¦ã®èª¬æãã覧ãã ããã
仿§æ¸
| Specification |
|---|
| The HTML Geolocation Element > # dom-htmlgeolocationelement-error > |
ãã©ã¦ã¶ã¼ã®äºææ§
é¢é£æ å ±
<geolocation>è¦ç´