2017-09-05 94 views
1

我是這個API的新手。我生成API密鑰,但我不知道如何實施谷歌地圖。如何獲得谷歌地圖的網絡當前位置

我搜索了很多,但沒有任何工作適合我。我需要幫助來查找用戶或設備當前位置。

我需要在我的網站上顯示谷歌地圖,指向使用angularjs設備的當前位置。

任何人都可以請建議我如何獲得當前位置谷歌地圖或任何教程在哪裏可以得到的代碼。

+0

檢查此代碼,這正是你想要的:https://github.com/allenhwkim/angularjs-google-maps/blob/master/testapp/map_with_current_position.html –

+0

這裏是該代碼的演示:https:// rawgit .com/allenhwkim/angularjs-google-maps/master/testapp/map_with_current_position.html –

回答

0

得到你需要的位置從導航本身 用簡單的HTML5地理位置代碼

<p id="demo"></p> 


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; 
} 

得到這個位置,通過它在地圖上後的當前位置,您的當前位置將顯示

+0

爲此,我需要使用任何外部鏈接 – sudarsan

+0

導航器是一個JS窗口對象,包含有關訪問者瀏覽器的信息,您將訪問不需要任何外部鏈接 –

+1

請參閱此處的實例https://www.w3schools.com /html/tryit.asp?filename=tryhtml5_geolocation –

相關問題