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
  • 福州街11號日式宿舍 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

CSS Radio Button

CSS Radio Butt...

寫系統的時候三不五時總會用到Radio Button 和 Checkboxes 目前就在寫這個部份@...

如何使用javascript判斷身分證號跟居留證格式

如何使用javascript...

首先,我是把如何用javascript判斷字串中必須包含中英文的方式延伸~ 將每一個字轉換成 ASC...

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

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

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

Recommended reading

Other stories happened at this address

有興趣寫故事的人可以自行加入開始安裝你自己的故事~

有興趣寫故事的人可以自行加入...

innstory 每個人,都有自己的故事。 故事,都值得被紀錄下來。 innstory紀錄你我的故事...

相簿功能導入

相簿功能導入

首先,非常感謝U今天肯給我個小時的時間。 讓我可以完成這個功能。 會想要這功能原因是我會有想要看照片...

apache下設置不顯示目錄列表 Indexes FollowSymLinks

apache下設置不顯示目錄...

pexelsphoto 選擇編輯httpd.conf文件 vi conf/httpd.conf 找到...

一家人平平安安最幸福

一家人平平安安最幸福

一家人平平安安最幸福

親子時間,​​​​​​​黏土時間。

親子時間,​​​​​​​黏土...

s 外頭滴滴答答的下著雨,正好陪著U玩黏土。 話說這個年紀的小孩最愛模仿,但這傢伙沒有模仿我做黏土的...

鍾5U你欠我一份大腸包小腸(╥﹏╥)

鍾5U你欠我一份大腸包小腸(...

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