【发布时间】:2015-12-03 20:11:09
【问题描述】:
我一直在努力研究如何将 google 的地理定位服务与 angular 模块 angular-google-maps 一起使用。使用这个模块让它变得很奇怪,并且不能以与普通谷歌地图 javascript v3 相同的方式进行地理定位。
例如:
var geocoder = new google.maps.Geocoder();
Google 未定义..
这是我目前为止的工作:
我的 angular.module:
...'uiGmapgoogle-maps'])
.config(['uiGmapGoogleMapApiProvider', function (GoogleMapApi) {
GoogleMapApi.configure({
key: 'X',
v: '3.20',
libraries: 'weather,geometry,visualization'
});
}]);
我的角度控制器:
.controller(...., function (.., uiGmapGoogleMapApi, GoogleMapApi){
//Map setup stuff
var geocoder = new GoogleMapApi.Geocoder();
geocoder.geocode( { 'address': 'something'}, function(results, status) {
if (status == GoogleMapApi.google.maps.GeocoderStatus.OK) {
$scope.map.control.getGMap().setCenter(results[0].geometry.location);
$scope.map.marker.latitude = results[0].geometry.location.lat();
$scope.map.marker.longitude = results[0].geometry.location.lng();
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
说地理编码器未定义。 非常困惑要使用什么对象,uiGmapGoogleMapApi 或 GoogleMapApi 来引用 Geocoder()。以及应该如何设置 geocoder.geocode..? 请帮忙
【问题讨论】:
标签: javascript angularjs google-maps google-maps-api-3 angular-google-maps