-1
我想从谷歌地图API的地址获取经度和纬度,我不明白它如何。地图通过获取地址来工作,但是有一种方法可以使地址获得经纬度?下面的代码工作:经纬度未保存谷歌地图API
<ng-map default-style="false" zoom="16" center="{{ '{{ getAddress() }}' }}" style="width: 100%; height: 430px;">
<marker centered="true" position="{{ '{{ getMarkerPosition() }}' }}" draggable="true" on-dragend="onMarkerDragEnd($event)"></marker>
<shape ng-if="showRegions" ng-repeat="shape in regions"
(...)
</shape>
</ng-map>
而且JS:
$scope.getMarkerPosition = function() {
if (!$scope.address.mapPinLocationLatitude || !$scope.address.mapPinLocationLongitude) {
return $scope.getObjectiveAddress();
}
return [$scope.address.mapPinLocationLatitude, $scope.address.mapPinLocationLongitude]
};
的问题是,mapPinLocationLatitude和长总是空,在数据库中没有获救,不知道为什么..
$scope.getAddress = function() {
var address = "..."; (here just concatenate the string with the address values(street, number, etc and it returned)
return streetString + ', ' + address;
};
$scope.onMarkerDragEnd = function ($event) {
$scope.address.mapPinLocationLatitude = $event.latLng.lat();
$scope.address.mapPinLocationLongitude = $event.latLng.lng();
$scope.updateRegions();
};
所以,我的问题是,任何想法如何获得纬度和长期,例如,如果我写:地图要正确显示?
<marker centered="true" position="{{ '{{ [address.mapPinLocationLatitude, address.mapPinLocationLongitude]}}' }}" draggable="true" on-dragend="onMarkerDragEnd($event)"></marker>
你想获得类似的问题LAT \ LNG从谷歌地图的地址? – Constantine
是的,这是我想要的 – IleNea