Skip to content

Commit

Permalink
reverseGeocode service example on README
Browse files Browse the repository at this point in the history
  • Loading branch information
guiassemany committed Feb 26, 2016
1 parent e2ac9ff commit ea02624
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,45 @@ angular.module('myApplication', ['AngularReverseGeocode']);
** Important: You should also have the google maps api script on your page! **

### How to use
The directive
```html
<reverse-geocode lat="-12.928615" lng="-38.509741"></reverse-geocode>
```

If the latitude and longitude variables are coming from scope variables set in a controller, you need to use curly-brace expression:

```html
<reverse-geocode lat="{{myCtrl.lat}}" lng="{{myCtrl.lng}}"></reverse-geocode>
```

---

The service
```javascript
(function() {
'use strict';

angular
.module('myApp', [
'AngularReverseGeocode'
])
.controller('MyCtrl',['reverseGeocode', '$scope', function(reverseGeocode, $scope){
var vm = this;
vm.lat = "-12.914090";
vm.lng = "-38.493835";

vm.formatted_address = "";

activate();

function activate(){
reverseGeocode.geocodePosition(vm.lat, vm.lng, function(address){
vm.formatted_address = address;
$scope.$apply();
});
}

}]);

})();
```

0 comments on commit ea02624

Please sign in to comment.