{"id":256770,"date":"2022-11-22T08:51:23","date_gmt":"2022-11-22T00:51:23","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=256770"},"modified":"2022-11-03T20:51:58","modified_gmt":"2022-11-03T12:51:58","slug":"to-html5-geolocation","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/to-html5-geolocation.html","title":{"rendered":"HTML5 Geolocation\uff08\u5730\u7406\u5b9a\u4f4d\uff09\u7b80\u4ecb"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | HTML5 Geolocation\uff08\u5730\u7406\u5b9a\u4f4d\uff09\u7528\u4e8e\u5b9a\u4f4d\u7528\u6237\u7684\u4f4d\u7f6e\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u5b9a\u4f4d\u7528\u6237\u7684\u4f4d\u7f6e<\/strong><\/div>\n HTML5 Geolocation API \u7528\u4e8e\u83b7\u5f97\u7528\u6237\u7684\u5730\u7406\u4f4d\u7f6e\u3002<\/p>\n \u9274\u4e8e\u8be5\u7279\u6027\u53ef\u80fd\u4fb5\u72af\u7528\u6237\u7684\u9690\u79c1\uff0c\u9664\u975e\u7528\u6237\u540c\u610f\uff0c\u5426\u5219\u7528\u6237\u4f4d\u7f6e\u4fe1\u606f\u662f\u4e0d\u53ef\u7528\u7684\u3002<\/p>\n \u6d4f\u89c8\u5668\u652f\u6301<\/strong><\/div>\n
\u6ce8\u610f: Geolocation\uff08\u5730\u7406\u5b9a\u4f4d\uff09\u5bf9\u4e8e\u62e5\u6709 GPS \u7684\u8bbe\u5907\uff0c\u6bd4\u5982 iPhone\uff0c\u5730\u7406\u5b9a\u4f4d\u66f4\u52a0\u7cbe\u786e\u3002<\/p>\n HTML5 - \u4f7f\u7528\u5730\u7406\u5b9a\u4f4d<\/strong><\/div>\n \u8bf7\u4f7f\u7528 getCurrentPosition() \u65b9\u6cd5\u6765\u83b7\u5f97\u7528\u6237\u7684\u4f4d\u7f6e\u3002<\/p>\n \u4e0b\u4f8b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5730\u7406\u5b9a\u4f4d\u5b9e\u4f8b\uff0c\u53ef\u8fd4\u56de\u7528\u6237\u4f4d\u7f6e\u7684\u7ecf\u5ea6\u548c\u7eac\u5ea6: var x=document.getElementById(\"demo\");\r\nfunction getLocation()\r\n{\r\n if (navigator.geolocation)\r\n {\r\n navigator.geolocation.getCurrentPosition(showPosition);\r\n }\r\n else\r\n {\r\n x.innerHTML=\"\u8be5\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u83b7\u53d6\u5730\u7406\u4f4d\u7f6e\u3002\";\r\n }\r\n}\r\n \r\nfunction showPosition(position)\r\n{\r\n x.innerHTML=\"\u7eac\u5ea6: \" + position.coords.latitude + \r\n \" |