Skip to content
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

Support use of ember-g-map from China #127

Open
arturalkaim opened this issue Feb 23, 2018 · 3 comments
Open

Support use of ember-g-map from China #127

arturalkaim opened this issue Feb 23, 2018 · 3 comments

Comments

@arturalkaim
Copy link

The url https://maps.googleapis.com/maps/api/js is blocked in China and http://maps.google.cn/maps/api/js should be used instead.

https://developers.google.com/maps/documentation/javascript/localization#GoogleMapsChina

Is there a way to handle this? Or only gracefully handle the error without breaking everything?

Thank you!

@steveszc
Copy link
Collaborator

I think the quickest fix would be to use the exclude: true option in config/environment.js and handle loading the google maps script yourself in your index.html. The best solution i can think of is to serve a different version of your index.html (with the google.cn script src) to users in China.

It'd be great if we could find a way to have the addon handle this, but I'm not sure there's a bullet-proof client-side solution for this problem. I'm open to suggestions though.

@arturalkaim
Copy link
Author

On my index.html I have:

  <script src="//maps.googleapis.com/maps/api/js" type="text/javascript"></script>
  /* Fallback for google maps api for China  */
  <script type="text/javascript">
    if (  typeof window.google == 'undefined' || typeof window.google.maps == 'undefined') {
      document.write(unescape('%3Cscript type="text/javascript" src="//maps.google.cn/maps/api/js" %3E%3C/script%3E'));
    }
  </script>

This way at least it's not breaking. This would also allow you to always load something in the plugin code.

But thanks! Your suggestion will probably fix my issue.

@steveszc steveszc changed the title Using ember-g-map from China breaks my app Support use of ember-g-map from China Feb 23, 2018
@steveszc
Copy link
Collaborator

I added a note about this in the readme in PR #128
I will leave this issue open for now. I think the solution @arturalkaim shared is reasonable but may not be appropriate as a default behavior for the addon. I'd still like to solve this in the addon though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants