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

Photoshop 曲線文字建置

Photoshop 曲線文字...

Photoshop一直都是很強悍的繪圖軟體。 裡頭的【鋼筆工具】,可以拉貝茲曲線的.... 我剛開始...

ajax防止重複提交

ajax防止重複提交

會發生重提交的原因,大致上是因為考驗人與系統間的耐性~ AJAX(非同步的JavaScript與XM...

解決手機瀏覽器上點擊輸入框放大問題

解決手機瀏覽器上點擊輸入框放...

開發RWD的網站已經是趨勢,主要也是因為手機用戶實在是太多 但在過程中一直有個問題困擾著我.... ...

Recommended reading

Other stories happened at this address

是說我的好日子快到了嗎???

是說我的好日子快到了嗎???...

個多月的U,目前喝奶方式已經進階到可以自己握著奶瓶~ 恩,是說我的好日子快到了嗎???

人生第一次拿到會飛的氣球,這傢伙開心到不行啊~

人生第一次拿到會飛的氣球,這...

人生第一次拿到會飛的氣球,這傢伙開心到不行啊~

看來白川鄉,得再去一次了~

看來白川鄉,得再去一次了~

看來白川鄉,得再去一次了~

紅燒豆腐佐海尼根

紅燒豆腐佐海尼根

e 其實我並不愛把豆腐弄熱來吃~ 小時後的記憶~豆腐就是該從冰箱拿出來淋上點醬油.... 冰冰涼涼的...

禦寒聖物,有了他,管他寒流來不來~

禦寒聖物,有了他,管他寒流來...

禦寒聖物,有了他,管他寒流來不來~

屬於自己的片刻

屬於自己的片刻

s 外頭下著雨。 Mandy跟U都已入睡~我卻捨不得入眠。 自從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