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

PHP的日期加減運算

PHP的日期加減運算

在再加上5天 = $years = date("Y"); //用date()函式...

ajax防止重複提交

ajax防止重複提交

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

querySelectorAll對多個相同ID做統一處理

querySelectorA...

a 範例,想將同一組ID的DIV做統一隱藏的動作 var elms = document.query...

Recommended reading

Other stories happened at this address

兄妹

兄妹

綠啊~爸爸在這裡幫妳做個紀錄,讓妳知道你哥哥是怎麼用他的方式來疼愛你的~ 這可是他最喜歡的貼紙啊~ ...

今晚,瓜仔肉拌飯

今晚,瓜仔肉拌飯

醬瓜切碎,蒜頭切片。 將處理好的醬瓜跟蒜頭跟絞肉一起拌勻。 順便也倒了些醬瓜的湯汁、一點米酒、一點醬...

你是否知道我故事中的角色?

你是否知道我故事中的角色?

那天~突然在想....... 有看我故事的人,是否會知道我寫的那些故事裡,裏頭的人事物對我有何意義?...

如何用javascript接收radio button被選取後的值

如何用javascript接...

剛剛竟然犯了最簡單的錯誤~ 而且還是在趕著時間的時候⊙⊙ 我竟然蠢到用接收input 的方式去接收 ...

到底要不要叫5U起來喝奶我很猶豫啊~

到底要不要叫5U起來喝奶我很...

雖然說不上是天人交戰~ 但他現在睡的那麼熟,我真的很猶豫到底要不要叫他起來喝奶啊...@@ 捨不得叫...

PDO連接Mysql方式 MVC上應用

PDO連接Mysql方式 M...

pexelsphoto 將連結資料庫的方式加入model function connect() { ...

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