获取坐标(经纬度)的谷歌地图的街道地址-角

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

本文关键字:谷歌地图 街道 地址 -角 坐标 经纬度 获取      更新时间:2023-09-26

我有一个随机的街道地址,比如:5707 dogwood ave.我想要的只是得到这个地址的坐标,这样我就可以使用angular查看我的谷歌地图上的街道位置。我已经搜索过了,但没有找到任何有用的。

地图代码(非常基本的地图)

$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包装器

如果你每天的请求超过2500个,我也会回顾一下这篇关于如何处理速率限制的文章。

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