From ea026241ed773befdaf4766dfc326e6f311447e6 Mon Sep 17 00:00:00 2001 From: Guilherme Assemany Date: Fri, 26 Feb 2016 12:55:53 -0300 Subject: [PATCH] reverseGeocode service example on README --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index d59985c..70b1c4e 100644 --- a/README.md +++ b/README.md @@ -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 ``` If the latitude and longitude variables are coming from scope variables set in a controller, you need to use curly-brace expression: + ```html ``` + +--- + +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(); + }); + } + + }]); + +})(); +```