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

Mysql最怕就是手賤

Mysql最怕就是手賤

今天我手賤了眼盲了@@... 錯把delete當成UPDATE....啃!!今天下午超不順的... ...

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

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

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

利用 css 讓 ul 置中呈現

利用 css 讓 ul 置中...

以前寫網站...總是喜歡用Table 包住內容.. 而隨著時空的轉換...現在大都用div..或者....

Recommended reading

Other stories happened at this address

將照片加入簽名檔

將照片加入簽名檔

我始終相信,科技來自於人性... 而我的人性則是來自於墮性.... 開發 innstory.com ...

兄妹

兄妹

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

When caterpillar grow up become butterfly

When caterpill...

When caterpillar grow up become butterfly

人生就應該像這頑強生命力的地瓜葉

人生就應該像這頑強生命力的地...

前幾天,隨手將準備丟棄的地瓜葉梗插進原本要種植香菜的盆裡。 過了快一個星期,竟然多了幾片綠意~ 我的...

這笑容是想甜死誰啊~

這笑容是想甜死誰啊~

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

看來我們家有好些日子可以充滿南洋風味~

看來我們家有好些日子可以充滿...

看來我們家有好些日子可以充滿南洋風味~

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