簡體   English   中英

通過街道地址獲取谷歌地圖的坐標(緯度和經度) - 角度

[英]get the coordinates(latitude and longitude) of google map by street address - angular

所以我有隨機的街道地址,讓我們說:5707山茱萸大道。 我想要的是獲取該地址的坐標,以便我可以使用角度在街道位置查看我的谷歌地圖。 我搜索但無法找到任何有用的東西。

地圖代碼(非常基本的地圖)

$scope.map = {
    center: {
        latitude: 33.025859,
        longitude: -96.844698
    },
    zoom: 8
};

HTML代碼:

<google-map class="full-image" center="map.center" zoom="map.zoom"></google-map>

您可以使用http.get在Google的API端點發出GET請求並檢索地址坐標的json:

$http.get('http://maps.google.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false').success(function(mapData) {
      angular.extend($scope, mapData);
    });

你可以在$scope.mapData調出數據

有關詳細信息,請參閱此StackOverflow帖子: Google Maps API - 獲取地址坐標

假設您擁有該地址,則可以使用Google Geocoding Web服務手動檢索位置坐標。 (我添加了一個城市和州,以便更好地優化數據) https://developers.google.com/maps/documentation/geocoding/

JSON:

http://maps.google.com/maps/api/geocode/json?address=5707%20dogwood%20ave.%20Rosamond,%20CA&sensor=false

XML:

http://maps.google.com/maps/api/geocode/xml?address=5707%20dogwood%20ave.%20Rosamond,%20CA&sensor=false

或者,API上有一個javascript包裝器

如果您每天超過2,500個請求,我還會審查這篇關於如何處理速率限制的帖子。

http://www.benbybenjacobs.com/blog/2013/09/11/google-geocoding-service-for-angularjs

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM