Google maps API


#1

HI everybody,

I’d like to use the google API in my app to localize in which region the client is. My question is where i have to import the api? And is there something lighter to not show the map, i need only to recognize the region.

Thank you


#2

A good place to start with 3rd party libraries is see if there is already an addon for it, check Ember Observer or Ember Addons. Chances are if it’s popular someone has already kindly integrated it for you!

In your case, ember-g-map might be one to try first


#3

If you want to roll your own solution, there are a few ways to get started:

  • just drop the Google API script tags in your index.html. The API should be available as global.
  • you could create an in-repo addon and add the script tag there, which will then be included at build time. Same result as before, the Google API will be available as global
  • Loading the API with initializers or services is another option, but probably too complex for your simple use case.

As alternative, you could try to identify the user location with the browser’s Geolocation API and then query Geonames (http://www.geonames.org/export/web-services.html), in case that yields results accurate enough for your use case.

There’s also Mapbox’s Geocoding API (https://www.mapbox.com/api-documentation/#list-tilesets), that’s a little lighter than Google’s.