Loading...

HTML5 Geolocation

Temperature: 0 °C

ChungChung
author_tools

說真的,HTML5 Geolocation的功能真的好用...

輕鬆就可以讓網站也能取得目前所在的地理位置

這次把它運用在innstory裡也是為了方便未來寫下動態或是故事,必竟住址比較不是那麼容易記下...

索性就把這工作交給系統~

<script>
var x = document.getElementById("demo");
function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else {
        x.innerHTML = "Geolocation is not supported by this browser.";
    }
}
function showPosition(position) {
    x.innerHTML = "Latitude: " + position.coords.latitude +
    "<br>Longitude: " + position.coords.longitude;
}
</script>

上述function只是取得座標位置,若要將座標轉換成地址還得靠下列function
var geocoder = new google.maps.Geocoder();
                    geocoder.geocode({ location: new google.maps.LatLng(lat, lng) },
                    function (results, status) {
                        if (status == google.maps.GeocoderStatus.OK) {
                            document.getElementById("address_guest").value =results[0].formatted_address;
                            }}
                            );

Url link

昨晚已把這功能也加入了innstory。

台北市內湖區江南街71巷75弄 Go

https://innstory.com/story-HTML5_Geolocation-575
寫程式筆記

Prev
 那桌上其實已消逝的記憶

Next
多桑__李鴻欽漫畫 

Nearby Attractions

台北市內湖區江南街71巷75弄-Nearby Attractions

  • 臺大昆蟲館 Go
  • 碧潭吊橋 Go
  • 艋舺助順將軍廟(晉德宮) Go
  • 芝山岩遺址 Go
  • 潘宮籌墓 Go
  • 總統府 Go

About the Author

Chung

我是chung
網路工作者
主業是網站系統開發建置
副業是做夢,寫故事
作品請參考/teme.biz
做夢請參考/innstory.com
聯絡/chung.teme@gmail.com

#有人用筆寫日記,有人用歲月寫日記,有人用照片寫日記,而我,用innstory寫日記。

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

地圖故事

地圖故事

map 一切都從第一張畫布開始... Innstory裡原先已有寫故事的功能,接著我把故事裡頭的照片...

修練中

修練中

假日二胡修練中。

分享到各社群的方式

分享到各社群的方式

每次在寫網站系統時..客戶總會要求希望他們的網站可以有分享到社群網站的功能... 所以把一些常用的方...

Recommended reading

Other stories happened at this address

認真蓋他的城堡,啟動小腦袋思考模式

認真蓋他的城堡,啟動小腦袋思...

認真蓋他的城堡,啟動小腦袋思考模式

我的第一次父親節,這傢伙卻只對蛋糕有興趣~

我的第一次父親節,這傢伙卻只...

年月日 終於,我確確實實的在過著父親節了。 雖然U還小,無法趁這機會帶他出去過節~ 在家裡,其實也挺...

當兒子非常非常需要你的時候~

當兒子非常非常需要你的時候~...

當兒子非常非常需要你的時候~ 不得不我只好改變我的工作環境.........(╯з╰) s 硬生生的...

一家人平平安安最幸福

一家人平平安安最幸福

一家人平平安安最幸福

PDO連接Mysql方式

PDO連接Mysql方式

pexelsphoto 最近因為源碼檢測的原因,才驚覺自己以前的系統撰寫的方式早已不再安全。 所以決...

2個小孩果然不容易

2個小孩果然不容易

離開舒適圈(月子中心)回到主戰場(一家四口甜蜜的家)也近個星期了。 我深深體會到照顧個小孩,果然艱困...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format