Search code examples
androidgoogle-mapsterrain

Google maps in my android app with GoogleMap.MAP_TYPE_TERRAIN washes out the contour lines and elevations


I'm testing some different map types in my application and I'd really like to leverage the topo map for certain areas and the MAP_TYPE_TERRAIN seems to have this. However, I've noticed than when I zoom in, I can initially see the contour lines and the elevations marked on the topo map, but then Google puts some other tile overlay on top of it that washes out the lines and the elevations. It makes for a neat effect because it gives it a 3D kind of feel, but I'd rather keep the actual topo info for my purposes. Is there a setting or something I can toggle to prevent the API from adding that extra layer? Again, as I said, I can see it there initially as I pan to a new area, or zoom in to a different tile set, it just subsequently gets washed out when Google is done painting the map.


Solution

  • There is no way to configure the default behavior of specific map types (TERRAIN, SATELITE, etc). What you can do is come up with your own custom TileOverlays.

    Here's a bit of intro about Tile Overlays.

    The simplest and most common way of creating a tile overlay is to provide a URL pointing to the relevant tile image. UrlTileProvider is a partial implementation of TileProvider that provides image tiles based on a URL. This class requires that all the images have the same dimensions.

    You will need to implement UrlTileProvider.getTileUrl(), which accepts the tile coordinates (x, y, zoom), and returns a URL pointing to the image to be used for the tile. The method should return null if there is no tile for the given x, y and zoom. A URL can point to a web resource, an Android asset, or a file on the local disk.