use of org.osmdroid.views.overlay.TilesOverlay in project collect by opendatakit.
the class MapHelper method showLayersDialog.
public void showLayersDialog(final Context context) {
AlertDialog.Builder layerDialod = new AlertDialog.Builder(context);
layerDialod.setTitle(context.getString(R.string.select_offline_layer));
layerDialod.setSingleChoiceItems(offilineOverlays, selectedLayer, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
switch(item) {
case 0:
if (googleMap != null) {
if (googleTileOverlay != null) {
googleTileOverlay.remove();
}
} else {
// OSM
if (osmTileOverlay != null) {
osmMap.getOverlays().remove(osmTileOverlay);
osmMap.invalidate();
}
}
selectedLayer = item;
break;
default:
File[] spFiles = getFileFromSelectedItem(item);
if (spFiles.length == 0) {
break;
} else {
File spfile = spFiles[0];
if (isFileFormatSupported(spfile)) {
if (googleMap != null) {
try {
// googleMap.clear();
if (googleTileOverlay != null) {
googleTileOverlay.remove();
}
TileOverlayOptions opts = new TileOverlayOptions();
GoogleMapsMapBoxOfflineTileProvider provider = new GoogleMapsMapBoxOfflineTileProvider(spfile);
opts.tileProvider(provider);
googleTileOverlay = googleMap.addTileOverlay(opts);
} catch (Exception e) {
break;
}
} else {
if (osmTileOverlay != null) {
osmMap.getOverlays().remove(osmTileOverlay);
osmMap.invalidate();
}
osmMap.invalidate();
OsmMBTileProvider mbprovider = new OsmMBTileProvider(iregisterReceiver, spfile);
osmTileOverlay = new TilesOverlay(mbprovider, context);
osmTileOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
osmMap.getOverlays().add(0, osmTileOverlay);
osmMap.invalidate();
}
selectedLayer = item;
} else {
ToastUtils.showLongToast(R.string.not_supported_offline_layer_format);
}
}
break;
}
dialog.dismiss();
}
});
layerDialod.show();
}
use of org.osmdroid.views.overlay.TilesOverlay in project android-sdk-examples by IndoorAtlas.
the class OpenStreetMapOverlay method onResume.
@Override
protected void onResume() {
super.onResume();
if (mOsmv == null) {
mOsmv = new MapView(this);
mOsmv.setTilesScaledToDpi(true);
mOsmv.setBuiltInZoomControls(true);
mOsmv.getController().setZoom(18);
mProvider = new MapTileProviderBasic(getApplicationContext());
mProvider.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
mTilesOverlay = new TilesOverlay(mProvider, getBaseContext());
mOsmv.getOverlays().add(mTilesOverlay);
mLayout = new RelativeLayout(this);
mLayout.addView(mOsmv, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
setContentView(mLayout);
}
// start receiving location updates & monitor region changes
mIALocationManager.requestLocationUpdates(IALocationRequest.create(), mListener);
mIALocationManager.registerRegionListener(mRegionListener);
}
use of org.osmdroid.views.overlay.TilesOverlay in project collect by opendatakit.
the class OsmDroidMapFragment method loadReferenceOverlay.
/**
* Updates the map to reflect the value of referenceLayerFile.
*/
private void loadReferenceOverlay() {
if (referenceOverlay != null) {
map.getOverlays().remove(referenceOverlay);
referenceOverlay = null;
}
if (referenceLayerFile != null) {
OsmMBTileProvider mbprovider = new OsmMBTileProvider(this, referenceLayerFile);
referenceOverlay = new TilesOverlay(mbprovider, getContext());
referenceOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
map.getOverlays().add(0, referenceOverlay);
}
map.invalidate();
}
Aggregations