3

Well, thats the question, I thought that it would be possible to do something like map.setSatellite(true); but is not possible in OSMdroid.

Another trouble is if its possible to download maps, because I need to work offline, and my boss says that it should be possible to download the maps. The only way I know to use offline maps is making the maps with mobac and then manually store them to consult.

I have read something about using bing, but im not sure, do you know another way to do it?, I guess I will need to be online to work with bing libraries. Am I right?

piet.t
  • 11,718
  • 21
  • 43
  • 52
Danstern
  • 127
  • 8

3 Answers3

1

I know it's too late to post this answer but for others, it will help

OpenStreetMap(OSM) does not offer any aerial imagery layer(satellite view). But using MAPBOX we can achieve satellite view in OSM.

To do this use the following code snippet:

Add this meta data in AndroidManifest

<meta-data
        android:name="MAPBOX_MAPID"
        android:value="satellite-streets-v11"/>
<meta-data
        android:name="MAPBOX_ACCESS_TOKEN"
        android:value="PUT_YOUR_MAPBOX_ACCESS_TOKEN"/>

Create MapBoxTileSourceFixed.java class as follow

//waiting for osmdroid #1718 to be fixed:
class MapBoxTileSourceFixed extends MapBoxTileSource {
    MapBoxTileSourceFixed(String name, int zoomMinLevel, int zoomMaxLevel, int tileSizePixels) {
        super(name, zoomMinLevel, zoomMaxLevel, tileSizePixels, "");
    }

    @Override public String getTileURLString(final long pMapTileIndex) {
        StringBuilder url = new StringBuilder("https://api.mapbox.com/styles/v1/mapbox/");
        url.append(getMapBoxMapId());
        url.append("/tiles/");
        url.append(MapTileIndex.getZoom(pMapTileIndex));
        url.append("/");
        url.append(MapTileIndex.getX(pMapTileIndex));
        url.append("/");
        url.append(MapTileIndex.getY(pMapTileIndex));
        //url.append("@2x"); //for high-res
        url.append("?access_token=").append(getAccessToken());
        String res = url.toString();
        return res;
    }
}

And finally set MapBoxTileSource in mapview as follow

OnlineTileSourceBase MAPBOXSATELLITELABELLED = new MapBoxTileSourceFixed("MapBoxSatelliteLabelled", 1, 19, 256);
    ((MapBoxTileSource) MAPBOXSATELLITELABELLED).retrieveAccessToken(this);
    ((MapBoxTileSource) MAPBOXSATELLITELABELLED).retrieveMapBoxMapId(this);
    TileSourceFactory.addTileSource(MAPBOXSATELLITELABELLED);
    map.setTileSource(MAPBOXSATELLITELABELLED);
    map.getOverlayManager().getTilesOverlay().setColorFilter(null);

Output:

enter image description here

see original repository here

Enjoy coding :)

Shivam Jamaiwar
  • 524
  • 1
  • 4
  • 14
0

You can use this code for google map satellite view

getMap().setMapType( GoogleMap.MAP_TYPE_SATELLITE );

and you can take refrence from this link also for implementing google map

https://code.tutsplus.com/tutorials/getting-started-with-google-maps-for-android-basics--cms-24635

and for the google map download you can use this reference https://stackoverflow.com/a/19184812/6869491

I hope it will help you

Amit Verma
  • 391
  • 2
  • 18
  • Thank you, i didn know that way to use satellital view in google maps, but we arent using google maps, we are using osmdroid, and there arent setMapType property. Im starting to think that is not possible to use satellital view without using third-party tools, like bing. – Danstern Jul 31 '17 at 16:02
0

You can use MapBoxTileSource, with mapbox.streets-satellite as MAPBOX_MAPID. You will have to request an Access Token on MapBox site.

OnlineTileSourceBase MAPBOXSATELLITELABELLED = new MapBoxTileSource("MapBoxSatelliteLabelled", 1, 19, 256, ".png");
((MapBoxTileSource) MAPBOXSATELLITELABELLED).retrieveAccessToken(this);
((MapBoxTileSource) MAPBOXSATELLITELABELLED).retrieveMapBoxMapId(this);
TileSourceFactory.addTileSource(MAPBOXSATELLITELABELLED);
mapView.setTileSource(MAPBOXSATELLITELABELLED);

And in the manifest:

    <meta-data
        android:name="MAPBOX_MAPID"
        android:value="mapbox.streets-satellite"/>
    <meta-data
        android:name="MAPBOX_ACCESS_TOKEN"
        android:value="... YOUR MAPBOX ACCESS TOKEN HERE ..."/>
MKer
  • 3,430
  • 1
  • 13
  • 18