Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Android API v2 in China - map load took around an hour

What I have: native android app that use Android Maps API v2 (native library)

Everything works good in Hong Kong and Ukraine. The problems came as soon as we step in China border. We have next problems:

  • Map is loading from 30 mins to about one hour.
  • Even when it's loaded, the map resolution is very low http://i.gyazo.com/d4f40e1a225bd48a90087c39a502e4a6.png
  • Google Map WORKS by itself: http://i.gyazo.com/dc85e3618c285ced5bba799053dd0306.png

What I know around China:

  • Google is not really friendly there, but our app is not the one that is used a google maps in China, so my problem probably is not a new one.
  • There is the option to use a google maps hosted locally in China - ditu.google.cn, but as soon as we are using the native app there is not an option now to use a web view of map instead of native implementation (we have a lot of customizations)
  • I know, that better do not use HTTPS with Google maps (you can read around this here: Google Maps Geolocation API for China)

The question is:

  • Could we somehow improve the load of map? Could we somehow override the google map source to use a ditu.google.cn?
  • Could we somehow disable HTTPS in Map API?
  • Any other solution around this problem, that can be applied based on google services. Maybe there is some undocumented features?

What is did not expect as an answer is something like "Use Baidu". I know Baidu and this is a veeerryyy backup option as soon as they have an api docs in chineese.

It's fare to add, that Geocoding API based on ditu.google.cn works good.

Looking forward, thank you!

like image 638
Evgeniy Labunskiy Avatar asked Oct 23 '14 08:10

Evgeniy Labunskiy


People also ask

Does Google Maps API work in China?

From Google website: The Google Maps APIs are served within China from http://maps.google.cn. When serving content to China, replace https://maps.googleapis.com with http://maps.google.cn.

Is Google map blocked in China?

Like all popular Google services, Google Maps too is banned in China. The map developed by Baidu search engine is widely considered the most popularly-used map in China.


1 Answers

Maybe you can't override the original tile source. But you can use TileOverlay to get maps tile from external server.

Usage example :

TileProvider tileProvider = new UrlTileProvider(256, 256) {

  //...

  @Override
  public URL getTileUrl(int x, int y, int zoom) {

    /* Define the URL pattern for the tile images */
    String s = String.format("http://my.image.server/images/%d/%d/%d.png",
        zoom, x, y);

    if (!checkTileExists(x, y, zoom)) {
      return null;
    }

    try {
      return new URL(s);
    } catch (MalformedURLException e) {
        throw new AssertionError(e);
    }
  }

  //...

}

You can replace the my.image.server with ditu.google.cn and use external server API to get tile images. In the Maps, you can set OnCameraChangeListener, so the application will load tiles from external server when the map is zooming or panning.

Read more : https://developers.google.com/maps/documentation/android/tileoverlay

like image 154
Hafizh Herdi Avatar answered Oct 05 '22 02:10

Hafizh Herdi