Javascript 在Google Angular Map api中,如何使用place_id获取位置详细信息?
我想使用place_id获取places信息位置、城市、州、经度、纬度、格式化的_地址。我正在获取错误Uncaught TypeError:undefined不是一个函数。我正在使用谷歌api获取地址。var service=new google.maps.places.PlacesServicemap中有使用map变量;因为我使用的是角度谷歌地图,所以我将$scope.map作为参数传递,而不是map。请检查以下代码,其中我错了,我是错误的,因为在PlaceService中传递$scope.map,该服务希望在中作为参数传递map HTMLJavascript 在Google Angular Map api中,如何使用place_id获取位置详细信息?,javascript,angularjs,google-maps,google-maps-api-3,Javascript,Angularjs,Google Maps,Google Maps Api 3,我想使用place_id获取places信息位置、城市、州、经度、纬度、格式化的_地址。我正在获取错误Uncaught TypeError:undefined不是一个函数。我正在使用谷歌api获取地址。var service=new google.maps.places.PlacesServicemap中有使用map变量;因为我使用的是角度谷歌地图,所以我将$scope.map作为参数传递,而不是map。请检查以下代码,其中我错了,我是错误的,因为在PlaceService中传递$scope.m
基于以上注释,var map=$scope.map.control.getGMap是解决方案
因此,对于其他使用angular google map的用户,您需要使用$scope.map.control.getGMap来获取当前地图实例。从何处获取未定义的不是函数?你能粘贴错误跟踪吗?@ZhenyangHua我正在定义,因为我正在PlacesService中使用$scope.map………PlacesServiceattrContainer:HtmlLevel | map,$scope.map只是一个对象文字,它不是映射类型或DOM。要获取映射类型的对象,请使用$scope.Map.control.getMap并将其解析为PlacesServicemap方法。@ZhenyangHua感谢您的回复,您是说像var-Map=$scope.Map.control.getMap然后将其放入内部吗PlacesServicemap@ZhenyangHua如果您能在回答部分给出解释,我将不胜感激。。。
<ui-gmap-google-map center='map.center' zoom='map.zoom' control='map.control' id="map-canvas">
<ui-gmap-markers models="markers" idkey="markers.id" coords="'coords'" >
</ui-gmap-markers>
</ui-gmap-google-map>
var map={
center: {
latitude:
longitude:
},
bounds : ,
zoom: 5,
control : {}
};
$scope.map = map;
var service = new google.maps.places.PlacesService($scope.map);
service.getDetails({ placeId: $scope.place_id}, function(place, status){
console.log('place='+place);
});