Created
August 7, 2015 13:31
-
-
Save lubiluk/7f3a187041e6797aefb1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myApp.directive('googleplaceAutocomplete', function () { | |
return { | |
restrict: 'A', | |
require: 'ngModel', | |
scope: { | |
googleplaceAutocompletePlace: '=?', | |
googleplaceAutocomplete: '=', | |
}, | |
link: function postLink(scope, element, attrs, model) { | |
var options = scope.googleplaceAutocomplete; | |
var autocomplete = new google.maps.places.Autocomplete(element[0], options); | |
google.maps.event.addListener(autocomplete, 'place_changed', function () { | |
scope.$apply(function () { | |
scope.googleplaceAutocompletePlace = autocomplete.getPlace(); | |
model.$setViewValue(element.val()); | |
}); | |
}); | |
scope.$on('$destroy', function () { | |
google.maps.event.clearInstanceListeners(element[0]); | |
}); | |
} | |
}; | |
}); |
@Nezahual to solve this warnings you have to add your api key and don't use sensor parameter.
https://developers.google.com/maps/documentation/javascript/get-api-key
The problem may be other thing.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=yourapikey&libraries=places"></script>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry but your modification of Easy AngularJS Directive for Google Places Autocomplete doesn't work. It gives me the following warnings: