Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to connect the Google Maps API through reverse proxy in my app?

I am working on an app where I want to use the Google Maps API.

The problem is the connection to Google Maps API server is unstable. Sometimes it's OK but other times it's blocked because I'm in China.

The solution I've come up with is to make all the Google Maps API requests through a reverse proxy. I can setup a server as a reverse proxy in American or Hong Kong where there is a steady connection to Google maps server.

Then I have to change the urls of all the Google Maps APIs in my app to point to my reverse proxy and the proxy will proxy_pass all the requests to Google Maps server.

There are a few questions I have about this:

How would I go about implementing the client side libraries? Do I have to change them? If so, can I just download the Google Maps JavaScript API file and change the domain names of the urls in it to the domain of my proxy server?

And how would I go about Android and iPhone apps? I'm uncertain whether the Android and iPhone SDKs will make the request with http protocol. If it is, how can I replace the domain names of the APIs with the domain name of my proxy server?

I thought maybe there is a way to catch all the http requests made in my app and modify them before they get sent but after googling for a while I've found it's hard to do.

So is it possible to do this with Android and iPhone apps? Or is there a better way to achieve it with a web app?

I also would like to know is it worth the effort to do this since the solution seems to be rather complex and using the Google Maps API is not a necessity because there are replacements to it in our country. I just prefer Google Maps API to them because of its neat API style and the prettier look of maps.

like image 649
treblam Avatar asked Jul 25 '14 11:07

treblam


People also ask

Can I integrate Google Maps in my app?

Open Android Studio, and click Create New Project in the Welcome to Android Studio window. In the New Project window, under the Phone and Tablet category, select the Google Maps Activity, and then click Next. Complete the Google Maps Activity form: Set Language to Java or Kotlin.

Is Google Maps API free for mobile apps?

You won't be charged until your usage exceeds $200 in a month. Note that the Maps Embed API, Maps SDK for Android, and Maps SDK for iOS currently have no usage limits and are at no charge (usage of the API or SDKs is not applied against your $200 monthly credit).

What maps API is best for your app?

Mapbox API The styled maps can be embedded into web applications with the provided JavaScript library or to mobile apps with the respective iOS and Android SDKs.


3 Answers

Your solution is a blatant violation of Google's terms and conditions.

10.1.1 (a) You must not access or use the Maps API(s) or any Content through any technology or means other than those provided in the Service, or through other explicitly authorized means Google may designate. For example, you must not access map tiles or imagery through interfaces or channels (including undocumented Google interfaces) other than the Maps API(s). https://developers.google.com/maps/terms

Legal issues aside, I think you answered your own question. "Google Maps API is not a necessity because there are replacements to it in our country".

But if your hell-bent on using Google Maps you can use their tiles with a 3rd party library like leaflet for web content. Native mobile apps are an entirely different problem though...one which I suspect is either a: not possible or b: not feasible.

like image 158
SKYWALKR Avatar answered Oct 19 '22 21:10

SKYWALKR


FWIW, this doc from Google states it is acceptable to cache map images.

https://developers.google.com/maps/premium/optimize-web-services#cache

like image 25
Matt Avatar answered Oct 19 '22 19:10

Matt


Significant correction to the accepted answer:

The cited section 10.1.1 no longer exists. Moreover, searching for the terms "authorized" or "other than" in the Terms & Conditions (T&C) returns no hits for a similarly worded replacement.

In conclusion, upon reading the T&C it appears that Google no longer explicitly says You must not access or use the Maps API(s) or any Content through any technology or means other than those provided in the Service nor does Google appear to provide a replacement.

T&C here: https://cloud.google.com/maps-platform/terms/

like image 1
Luke Knoble Avatar answered Oct 19 '22 20:10

Luke Knoble