Search code examples
androidbitmapmapsandroid-mapview

android generate bitmap from google map without mapView


I want to generate a bitmap file using google maps without passing data through a mapView, like a background thread (downloading tiles in order to write the bitmap)

Does anyone has an idea?

an example is: entering coordinates and after clicking a button, the .png is generated in the SD Card, containing the COMPLETE loaded tiles.

any proposals?

thanks!!!


Solution

  • This method returns url with map image

    public static String getMapUrl(Double lat, Double lon, int width, int height) {
        final String coordPair = lat + "," + lon;
        return "http://maps.googleapis.com/maps/api/staticmap?"
                + "&zoom=16"
                + "&size=" + width + "x" + height
                + "&maptype=roadmap&sensor=true"
                + "&center=" + coordPair
                + "&markers=color:black|" + coordPair;
    }
    

    You can download or display it on ImageView