Using google maps API with varied domains - google-maps

Ok, so I have a site that uses the google maps API, and I want to serve it from more domains. The fact that the API key is tied to a domain greatly hinders my efforts on this front.
Is there any solution more elegant than getting a key for every domain?

There is one way you can avoid using the API key completely - use the version 3 API.
The v3 API is still in 'beta' but it has the key (no pun intended) functionality that most people use for their maps and there are no keys required. Nor will there be in the future according to Google. If you can get by without features like draggable markers, then v3 will work well. I use it for my primary map page and have no problems with it.

You can set up a proxy. But obviously that will complicate your code, and it's your responsibility to make sure only your domains can access the proxy.

Related

How come one doesn't need a Google Maps API Key to do this?

These 2 sites have some sample code on them. I copied and pasted the code into a php page in localhost, and they worked fine. However, the code doesn't seem to contain any API Keys. How come Google allows the code to use the Maps API without Keys? I'm obviously missing something here. What is it? Are there use cases where API Keys are not necessary? Where can I see the documentation regarding such uses cases?
http://www.codeofaninja.com/2014/06/google-maps-geocoding-example-php.html
https://gist.github.com/lazarofl/3901081#file-geocoder_example-html
The Google Maps JavaScript API v3 does not require an API key to function correctly. However, we strongly encourage you to load the Maps API using an APIs Console key which allows you to monitor your application's Maps API usage
From: https://developers.google.com/maps/signup

Can a Single Key (Bought From Google) work for all applications

So, I have bought a key from google for translation; I'm using it and it works as expected. Now there 's another requirement from client to use google maps in his application. Should I have to buy another key for the google map application, or is there anything like a master api key which'll work for all google applications?
Different APIs have different requirements for monitoring and managing usage. Depending on your use case you may or may not have to pay for using Google Maps. And no, there is no master API key that gives you access to all Google APIs.

use multiple Google Maps API Keys for same server?

I have a server which acts as a mesh.
I have 3 mobile apps, each having it's own google maps api Key
all three apps call my server which calls the google apis with the specific app key.
so App1 has key1
App2 has Key 2
App3 has key 3
when I need the directions for App1, my server calls google api with key 1
when I need the directions for App2, my server calls google api with key 2
when I need the directions for App3, my server calls google api with key 3
So my server works like an API mesh. Is this against google terms? I am afraid they will look at the ip address of the server, see there are 3 keys used and assume I am using different Keys for same applications which is prohibited.
The short answer (drawn from the FAQ) is quite simply : no, you can't use two keys in this case.
See https://developers.google.com/maps/faq#usage_avoidance
- they even reserve "the right to withhold access to the maps API from any site" doing so, just as you feared.
Using more than one key, even though it could only be a matter of convenience for you, means for them trying to cheat and bypass the limitation of 25,000 requests per day and per service. And they don't like that, because they want big users of their maps API to pay, of course. Prices are listed on the same page.
You should read the FAQ paragraphs "Understanding the Terms of Service" and "Usage limits" completely - it is quite short but sometimes a little tricky. You'll see that there are a few situations in which you do not actually have to pay even when exceeding limitations :
you are using the google earth API
you are using a native maps API from a mobile platform
you are showing a google map through an embed only
your apps are "in the public interest (as determined by Google at its discretion)"
Also, you do not always need to provide an API key, though these products may still be available for limited use only : take for instance the geocoding API.
I guess you're not in one of those cases (at least bullets 2 and 3) since your calls transit through your server. Using the native APIs in mobile apps would solve the problem, but it does mean quite some development I guess.
It is also worth noting that you should apply for a special maps API for business license for some use cases, e.g. when only paying users get to see your map.
In conclusion, you need to have one single google maps API key when it comes to using their products that require one. Or rather, at most one per domain name.

Google Maps JavaScript API V3 - API Key and clientId

After reading many online forums/blogs, it's pretty clear to me that Google Maps API V3 do not require API key anymore.
And for more advanced google map features, I should have clientId (which my organisation already have).
But what is confusing to me is that I found two places -
First, where I get the information that API key is still good to use
'All Maps API applications should load the Maps API using an API key'
Google Maps JavaScript API V3 Documentation
Second, where I get information that we should definitely avoid using API key and replace them with clientId
https://groups.google.com/forum/#!topic/google-maps-js-api-V3/oJf7I5FdAdY
http://egis3.lacounty.gov/eGIS/2011/12/06/google-maps-api-v3-to-stop-ignoring-the-key-parameter/
Can please guide if I am missing something and which one should I take as the correct information.
Thank you!
I think if the documentation says "All Maps API applications should load the Maps API using an API key," then that is the advice to follow. It's probably better advice than postings in a forum (including, perhaps, this one).
It's true that Version 3 will work without a key; but there is no guarantee that they will continue to do so, particularly in the light of the documentation; and using a key brings the benefits of statistics reporting.
The client ID is associated with an Enterprise licence, which raises some of the limits associated with a ordinary free key. Neither unlocks advanced features of the map; both allow usage reporting.
Yes, you have missed something !
The two links you give at the end of your question relate to moving from v2 of the API (where a key was obligatory) to v3 of the API where a key is optional.
It is not necessary to have a key for v3 of the API if you will not have more than 25000 map loads per day.
Over this limit, it is apparently required that you obtain a key and a premium account (payable).
Ensure that you have really understood the contents of the first link you gave, notably the section Obtaining an API key.
Then jump to the linked page on Usage Limits.
I reiterate what I have said : it is NOT required that you have an API key for v3.

Domain based security for widgets

The web sites will be register and get an API key to use widgets. For example; Site A is registered as sitea.com for widget. But the main problem is, the widget can not be accessable from siteb.com with API key of sitea.com. Are there any way to implement this?
The API keys for Google Maps are similar. There, you specify a key and it is checked every time against your domain. However, it is hard to get this secure. With Google Maps you can simply change the Javascript so that it does not check the API key anymore.