ion-google-place
ion-google-place copied to clipboard
Choose country to geocode
Hi,
I want to ask about how can I set up that only search in a country (Example: USA) . So what can I do with file .js? And How can I set 2
Thank you!
Best regards, DK
Use special attribute for it: geocode-options="value"
Example:
<ion-google-place ng-model="model" placeholder="placeholder" geocode-options="value" />
Sorry, but I have no idea what the value should be in the case. I tried to set
geocode-options="options"
$scope.options = {
types: '(cities)',
country: 'ca'
};
But this doesn't work. Could you please give some examples @ArtemNikolaev
Thanks!
Sorry for the wait @AleksMeshkov . Let me just show you how i do it in my app:
In view it looks like this:
<ion-google-place ng-model="..." placeholder="..." geocode-options="geocodeOptions" />
In controller it looks like this:
$scope.geocodeOptions = {
componentRestrictions: {
country : 'NL'
}
};
It works fine in my app.
@ArtemNikolaev thank you very much! Appreciate you help!
i did exactly the same thing didn't work :( @ArtemNikolaev
@edmamerto, Are you sure, that you are use right country code? Specification says: Matches a country name or a two letter ISO 3166-1 country code. If problem in other thing, post here your code, trying to find a problem
this isn't working for me either
$scope.geocodeOptions = {
componentRestrictions: {
country: 'US'
}
};
<ion-google-place geocode-options="geocodeOptions" />
didn't work for me too :/
For all the guys having a problem... First it was also not working for me. Seems like bower/ionic is downloading an older (more compatible) version. Check for those lines in the ion-google-place.js. Maybe you have an older version as well:
scope: {
ngModel: '=?',
geocodeOptions: '=',
currentLocation: '@'
}
var req = scope.geocodeOptions || {};
req.address = query;
geocoder.geocode(req, function(results, status) {