Ng-map get address after dragging marker Ng-map get address after dragging marker angularjs angularjs

Ng-map get address after dragging marker


In the function $scope.getCurrentLocation(), it receives a parameter, you can use it to get the location (lat,lng) for the marker.

Your code would be:

$scope.getCurrentLocation = function(event){        console.log(event.latLng.lat());        console.log(event.latLng.lng());}


There is a directive online that does the reverse geocoding. It is great and you can directly use in your code to serve the purpose of converting the lat/lng obtained after dragging the marker to a valid address.

Please take a look at this tutorial that has the directive code too.


You can take a look that this example, and take advantage of it.Google has its own way to achieve reverse geocoding

Documentation: https://developers.google.com/maps/documentation/javascript/examples/geocoding-reverse

Example: http://plnkr.co/edit/rSKZR8?p=preview

   this.doSth = function() {      geocoder.geocode({'location': this.getPosition()}, function(results, status) {        if (status === google.maps.GeocoderStatus.OK) {          if (results[1]) {            console.log(results[1]);          } else {            window.alert('No results found');          }        } else {          window.alert('Geocoder failed due to: ' + status);        }      });}