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

Linux底下Apache啟動、停止、重啟指令

Linux底下Apache啟...

a5 如果apache安裝成為linux的服務的話,可以用以下命令操作: service httpd...

研究著vps的設定...

研究著vps的設定...

現在在研究著vps的設定... 上次發生怪客入侵事件後...原本已經把所有系統都重新檢查後移入國內空...

清除網頁暫存(no cache)

清除網頁暫存(no cach...

pexelsphoto5 在製作專案時,有沒有試過JS 或 CSS 明明就已經更新了~ 但頁面卻像鬼...

Recommended reading

Other stories happened at this address

沒有菸抽的日子

沒有菸抽的日子

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

努力過的汗水最令人激賞!!

努力過的汗水最令人激賞!!

明明是在冷氣房裡,卻弄到滿頭大汗。 因為~他剛剛努力的用力,並且完成大便的使命。 就知道你可以的兒子...

windows下合併多個ISO檔為一個!

windows下合併多個IS...

所謂ISO檔就是副檔名為【.iso】的檔案一般稱為【光碟映像檔】。 我們可以透過某些燒錄軟體將整張裝...

邁進6個月

邁進6個月

s 兒子在Mandy肚子裡邁入個多月了~ 最近胎動的很厲害,真的辛苦了兒子的媽~ 每天隔著肚皮跟他說...

When caterpillar grow up become butterfly

When caterpill...

When caterpillar grow up become butterfly

果然,光要畫好一隻眼睛,也著實的不容易啊~

果然,光要畫好一隻眼睛,也著...

s 果然,光要畫好一隻眼睛,也著實的不容易啊~ 但不管怎樣,這次畫的有比上回好太多了。 真的,我越來...

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