我正在使用Angular UI Google Maps,并尝试从点击地图的位置获取latlng。目前地图正在返回响应,但没有latlng。请参阅下面的代码:
控制器
$scope.map = {
center: {
latitude: 45, longitude: -73
},
zoom: 8,
events: {
"click": function (event) {
console.log(event.latlng);
}
}
};
HTML
<ui-gmap-google-map events="map.events" center='map.center' zoom='map.zoom'></ui-gmap-google-map>
来自点击的响应:
Ln {gm_bindings_: Object, __gm: Wh, gm_accessors_: Object, mapTypeId: "roadmap", center: df…}__e3_: Object__gm: Whbounds: undefinedcenter: dfcontrols: Array[14]data: ghfeatures: UgetOptions: function () {gm_accessors_: Objectgm_bindings_: ObjectmapDataProviders: "Map data ©2014 Google"mapTypeId: "roadmap"mapTypes: DgmapUrl: "http://maps.google.com/maps?ll=45,-73&z=8&t=m&hl=en-US&gl=US&mapclient=apiv3"overlayMapTypes: lgstreetView: Uhtilt: 0tosUrl: "http://www.google.com/intl/en-US_US/help/terms_maps.html"uiGmap_id: "4b1e4213-59cd-4016-baac-2aa2af44fe1a"zoom: 8__proto__: c
如果您需要更多代码,请告诉我们。
由于
答案 0 :(得分:0)
事实证明该事件会将其作为第三个参数的数组返回,请参阅下面的修复程序。我希望这有助于某人:)
$scope.map = {
center: {
latitude: 45, longitude: -73
},
zoom: 8,
events: {
"click": function (event, a, b) {
console.log(a);
console.log(b);
}
}
};