问题描述
我想找到用户在地图上选择的location name 。
目前我正在获得经纬度。
但无法获得位置名称。
我正在使用angularJS和angular-google-maps 2.1.5.
这是html。
<ui-gmap-google-map center="map.center" zoom="map.zoom" draggable="true" options="options" events="map.events">
</ui-gmap-google-map>
JS:
$scope.map = {
center: {
latitude: 21.0000,
longitude: 78.0000
},
zoom: 4,
events: {
click: function(mapModel, eventName, originalEventArgs,ok) {
var e = originalEventArgs[0];
objOneDevice.dev_latitude = e.latLng.lat();
objOneDevice.dev_longitude = e.latLng.lng();
$scope.templatedInfoWindow.show = true;
}
}
};
$scope.options = {
scrollwheel: true
};
任何事情都表示赞赏。
1楼
RIYAJ KHAN
12
已采纳
2015-08-07 08:19:04
这是我使用所做的。
$scope.map = {
center: {
latitude: 21.0000,
longitude: 78.0000
},
zoom: 4,
events: {
click: function(mapModel, eventName, originalEventArgs,ok) {
var e = originalEventArgs[0];
var geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(e.latLng.lat(), e.latLng.lng());
geocoder.geocode({ 'latLng': latlng }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
console.log(results[1].formatted_address); // details address
} else {
console.log('Location not found');
}
} else {
console.log('Geocoder failed due to: ' + status);
}
});
}
}
};
2楼
Raj Kantaria
1
2015-08-07 06:30:27
在给定纬度/经度对象的情况下,您可以使用Google Map API将位置映射到大致地址。 您可以使用地理编码API将位置映射到地址和地址。
Geocoder.geocode( { 'latLng': latLngObject }, callbackFn);
是Google Map API进行地理编码的链接。
3楼
Megha Nagpal
1
2015-08-07 06:45:48
试试这些链接
使用地理编码API将位置映射到地址和地址。
Geocoder.geocode({'latLng':latLngObject},回调);
希望能帮助到你!!!