-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How TO change componentRestrictions -- Country Dynamically? #103
Comments
To be able to do this, I had to do a little digging and that is the solution I find online. For instance, you want to pass your current location dynamically as the country. Google has the Geolocation API that can be called and used to get current location. To do this, since you're already using the Google API I'm sure you already have the Keys setup. Go and enable the Google Geolocation API as part of your project as well. Next, you need to enable Google GeoCoding as part of your APIs from Google as well. With this you can now pass your lat and lng to Google Geocode to return a response. This is known as reverse geocoding by Google. Again this is the link to the docs here . Added the result type to country as that is what I want. Now after getting this, I can save the value of the country code to a variable and then pass this to the options object, before it is passed to the Input field to restrict the places to your country dynamically. I hope this helps. You can ask this as a Stack Overflow Question and I provide the answer. I believe it will help a lot. |
I think what he is asking is, how can one "change" the country restriction... this seemingly is only applied once on INIT. Google's JS API does support changing this via public API, but no support is enabled on this component for that kind of behavior. |
Expecting what @sscholle said. We are not able to put multiple countries under componentRestriction because |
Maybe this one can help you |
I want to change componentRestrictions country dynamically.
The text was updated successfully, but these errors were encountered: