Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to take google maps snapshot without actually displaying the map

I want to be able to take a screenshot of a certain location in google maps without actually loading the google map onto the screen, If there is a way google map can take the screenshot in the background that would be great.

like image 889
Errol Green Avatar asked Apr 25 '15 20:04

Errol Green


Video Answer


1 Answers

There is Lite Mode:

The Google Maps Android API can serve a static image as a 'lite mode' map.

A lite mode map is a bitmap image of a map at a specified location and zoom level. Lite mode supports all of the map types (normal, hybrid, satellite, terrain) and a subset of the functionality supplied by the full API. Lite mode is useful when you want to provide a number of maps in a stream, or a map that is too small to support meaningful interaction.

Example:

As an XML attribute for a MapView or MapFragment

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    android:name="com.google.android.gms.maps.MapFragment"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    map:cameraZoom="13"
    map:mapType="normal"
    map:liteMode="true"/>

In the GoogleMapOptions object

GoogleMapOptions options = new GoogleMapOptions().liteMode(true);

Here You can find supported features.


In addition I recommend reading: Android Google Map to show as picture

You can use the Google Maps built-in snapshot method, to capture a preview and display it in an ImageView.

like image 151
Ziem Avatar answered Oct 31 '22 06:10

Ziem