Search in sources :

Example 11 with TileOverlayOptions

use of com.google.android.gms.maps.model.TileOverlayOptions in project Ushahidi_Android by ushahidi.

the class Util method setMapTile.

/**
 * Sets which map tile to use
 *
 * @param context The calling Activity
 * @param map The GoogleMap
 */
public static void setMapTile(Context context, GoogleMap map) {
    // load preferences
    Preferences.loadSettings(context);
    TileOverlayOptions osm = new TileOverlayOptions().tileProvider(new OpenStreetMapTileProvider());
    TileOverlayOptions mapbox = new TileOverlayOptions().tileProvider(new MapBoxTileProvider());
    final String mapTile = Preferences.mapTiles;
    if (map != null) {
        map.setMapType(GoogleMap.MAP_TYPE_NONE);
        map.addTileOverlay(osm).remove();
        map.addTileOverlay(mapbox).remove();
        map.clear();
        if (mapTile.equals("google")) {
            map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        } else if (mapTile.equals("osm")) {
            map.addTileOverlay(osm);
        } else {
            map.addTileOverlay(mapbox);
        }
    }
}
Also used : TileOverlayOptions(com.google.android.gms.maps.model.TileOverlayOptions) MapBoxTileProvider(com.ushahidi.android.app.MapBoxTileProvider) OpenStreetMapTileProvider(com.ushahidi.android.app.OpenStreetMapTileProvider)

Aggregations

TileOverlayOptions (com.google.android.gms.maps.model.TileOverlayOptions)11 TileProvider (com.google.android.gms.maps.model.TileProvider)6 MalformedURLException (java.net.MalformedURLException)5 URL (java.net.URL)5 LatLng (com.google.android.gms.maps.model.LatLng)4 UrlTileProvider (com.google.android.gms.maps.model.UrlTileProvider)4 Intent (android.content.Intent)3 GoogleMap (com.google.android.gms.maps.GoogleMap)3 OnMapReadyCallback (com.google.android.gms.maps.OnMapReadyCallback)3 TileOverlay (com.google.android.gms.maps.model.TileOverlay)3 DialogInterface (android.content.DialogInterface)2 ActionBar (android.support.v7.app.ActionBar)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 CameraPosition (com.google.android.gms.maps.model.CameraPosition)2 JSONObject (org.json.JSONObject)2 AlertDialog (android.app.AlertDialog)1 SharedPreferences (android.content.SharedPreferences)1