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

CSS透明度

CSS透明度

CSS 透明度的實作, 各種瀏覽器和標準如下:(數字越小越透明) 標準: opacity:~ (Fi...

.sql檔過大無法匯入phpMyAdmin

.sql檔過大無法匯入php...

修改phpMyAdmin資料夾中的config.inc.php檔。 打開後找到下列兩行或自行加入: ...

php函式紀錄

php函式紀錄

常常忘記,只得紀錄下來...... AddSlashes: 字符串加入斜線。 binhex: 二進位...

Recommended reading

Other stories happened at this address

鹽烤鯖魚佐高粱

鹽烤鯖魚佐高粱

那年,我為了烤地瓜而買的烤箱,這些年來真的只是為了烤地瓜而存在。 自從上次開箱烤了香魚後,終於也發現...

參巴炒四大天王佐檳城的記憶

參巴炒四大天王佐檳城的記憶

s 這幾天,同Mandy在住家附近的市場發現了楊桃豆。 老實說,這東西我第一次吃也是在檳城美食中心,...

串接opendata氣象資訊

串接opendata氣象資訊...

研究了幾天的opendata(政府資訊開放平台)https:...

聽說今天是父親節啊~

聽說今天是父親節啊~

給U吃餅乾~ 結果他把餅乾弄碎了給我當痱子粉抹在身上.... 現在整個身體倒是充滿了千層鬆塔的甜味....

這笑容是想甜死誰啊~

這笑容是想甜死誰啊~

回到台北幾天了~這幾天常見到他笑。 原本有些小擔心....因為在南部住了一段時間,回到台北後不知道他...

Taare Zameen Par 心中的小星星

Taare Zameen P...

晚餐時間,看了一部印度電影【Taare Zameen Par】 taarezameenpar 一部很...

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