I am new to angular js. How can I implement geocoding services? Specifically, when I fill in a full address, how can I then populate the other fields (postal code,city,country,lat and lng) automatically?
I want to achieve something like this page in angular.
Please help me out.
I have code to populate the full address:
app.directive('googlePlaces', function(){
return {
restrict:'E',
replace:true,
// transclude:true,
scope: {location:'='},
template: '<input type="text" id="fulladdress" name="fulladdress" ng-model="enterprise.fulladdress" class="form-control text-field" placeholder="">',
link: function($scope, elm, attrs){
var autocomplete = new google.maps.places.Autocomplete($("#country")[0], {});
google.maps.event.addListener(autocomplete, 'place_changed', function() {
var place = autocomplete.getPlace();
$scope.location = place.geometry.location.lat() + ',' + place.geometry.location.lng();
$scope.$apply();
});
}
}
});
and the HTML:
<div class="form-group enterprise-form">
<label>Full Address</label>
<google-places location=location></google-places>
</div>
I want to populate two or three more fields lat,lng, postal code. Can I extend my directive to achieve this, and if so how?