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

恭喜

恭喜

5U個性比較文靜對於一些活動並不會主動積極的參與。 這回,在Mandy的鼓勵下,他參加了班上的說故事...

PHP數字1000分位逗號分隔函數number_format()

PHP數字1000分位逗號分...

有時候我們必需將數字加上每三個位數加上一個逗號(千分位),例如變成,,我雖不常用...但偶爾要用到時...

圖型插件Elastislide

圖型插件Elastislid...

teach Elastislide是一款好用的圖形插件......

Recommended reading

Other stories happened at this address

惱人的厭奶期

惱人的厭奶期

第天,以前安份努力的喝奶,每次餵他都超有成就感的,不誇張,每每我都期待著他打破奧運紀錄。 到現在每次...

果然還是紅白機對了胃口~

果然還是紅白機對了胃口~

果然還是紅白機對了胃口~

2014年的最後一天...

2014年的最後一天...

今天是年月日....年的最後一天... 回顧這一年來...甜頭苦頭都嚐過了.....就連最後一天的今...

6個月

6個月

已經個月了,從哇哇墜地到現在~看看U到底學會了什麼? 左翻右翻連續翻真的是沒有難度了 終於也是到了考...

兒子,吃香蕉要剝皮好嗎⊙_⊙

兒子,吃香蕉要剝皮好嗎⊙_⊙...

兒子,吃香蕉要剝皮好嗎⊙⊙

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

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

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

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