I'm trying to get the latitude and longitude from an address with google maps api and I don't get it how. The map is working by getting the address but there is a way for that address to take the lat and lon? The following code is working:
<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>
And the js:
$scope.getMarkerPosition = function () {
if (!$scope.address.mapPinLocationLatitude || !$scope.address.mapPinLocationLongitude) {
return $scope.getObjectiveAddress();
}
return [$scope.address.mapPinLocationLatitude, $scope.address.mapPinLocationLongitude]
};
The problem is that mapPinLocationLatitude and long are always null, in database are not salved and don't know why..
$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();
};
So, my question is, any idea how to get the latitude and long and for example if I write: the map to be displayed correctly?
<marker centered="true" position="{{ '{{ [address.mapPinLocationLatitude, address.mapPinLocationLongitude]}}' }}" draggable="true" on-dragend="onMarkerDragEnd($event)"></marker>