ion-google-place icon indicating copy to clipboard operation
ion-google-place copied to clipboard

Choose country to geocode

Open SkyDK opened this issue 9 years ago • 9 comments

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 with 2 ng-model in 1 file .html? I'm a newbie. :( Sorry about my English,

Thank you!

Best regards, DK

SkyDK avatar Mar 10 '15 10:03 SkyDK

Use special attribute for it: geocode-options="value" Example: <ion-google-place ng-model="model" placeholder="placeholder" geocode-options="value" />

ArtemNikolaev avatar Mar 11 '15 15:03 ArtemNikolaev

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!

AleksMeshkov avatar Mar 20 '15 15:03 AleksMeshkov

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 avatar Mar 26 '15 07:03 ArtemNikolaev

@ArtemNikolaev thank you very much! Appreciate you help!

AleksMeshkov avatar Mar 26 '15 12:03 AleksMeshkov

i did exactly the same thing didn't work :( @ArtemNikolaev

edmamerto avatar Apr 27 '15 18:04 edmamerto

@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

ArtemNikolaev avatar Apr 28 '15 06:04 ArtemNikolaev

this isn't working for me either

$scope.geocodeOptions = {
    componentRestrictions: {
      country: 'US'
    }
  };

<ion-google-place geocode-options="geocodeOptions" />

jtmarmon avatar Feb 12 '16 17:02 jtmarmon

didn't work for me too :/

hfcipriano avatar May 07 '16 21:05 hfcipriano

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) {

matthiasprieth avatar Feb 21 '17 17:02 matthiasprieth