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

分享到各社群的方式

分享到各社群的方式

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

黑客松Hackathon(二)

黑客松Hackathon(二...

這是一次不同的體驗... 我一直都渴望有所謂的工作團隊並且享受共同討論共同創作的樂趣... 這次在黑...

定義404頁面

定義404頁面

什麼是頁面? HTTP 或Not Found錯誤訊息是HTTP的其中一種「標準回應訊息」(HTTP狀...

Recommended reading

Other stories happened at this address

鹽烤香魚

鹽烤香魚

香魚我是很愛吃,但從來沒自己調理過.... 假日,表姐為了讓孕媽咪多補充點營養。所以帶上一盒香魚過來...

5U的第一張塗鴉作品,真是精彩啊~

5U的第一張塗鴉作品,真是精...

U的第一張塗鴉作品,看來正朝著畢卡索之路前進^^ 偏愛重口味顏色,不喜歡被框框侷限。 真的是無敵抽象...

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

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

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

童言童語,也太有禮貌篇...

童言童語,也太有禮貌篇......

U最近喜歡說的單字是「謝謝 」,而且也學會了在單字後面加上對象。 遞個東西給他,會說謝謝(爸爸),會...

沒有菸抽的日子

沒有菸抽的日子

老婆臨盆在即,但確不知道是何時。 兒子感冒,沒了精神沒了食慾。 手邊的專案號要交測試連結。 之前還有...

5U日常,我突然覺得那蛋捲盒子有點可憐~

5U日常,我突然覺得那蛋捲盒...

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