本文整理汇总了Java中org.osmdroid.tileprovider.MapTileProviderArray类的典型用法代码示例。如果您正苦于以下问题:Java MapTileProviderArray类的具体用法?Java MapTileProviderArray怎么用?Java MapTileProviderArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapTileProviderArray类属于org.osmdroid.tileprovider包,在下文中一共展示了MapTileProviderArray类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setOfflineMap
import org.osmdroid.tileprovider.MapTileProviderArray; //导入依赖的package包/类
public void setOfflineMap(String mapname) throws FileNotFoundException {
mFile = new File(Environment.getExternalStorageDirectory(), "/" + mapname);
if (!mFile.exists()) {
throw new FileNotFoundException();
}
MapTileModuleProviderBase treasureMapModuleProvider = new MapTileFileArchiveProvider(new SimpleRegisterReceiver(mContext),
mTreasureMapTileSource, new IArchiveFile[] { MBTilesFileArchive.getDatabaseFileArchive(mFile) });
MapTileProviderBase treasureMapProvider = new MapTileProviderArray(mTreasureMapTileSource, null,
new MapTileModuleProviderBase[] { treasureMapModuleProvider });
TilesOverlay treasureMapTilesOverlay = new TilesOverlay(treasureMapProvider, mContext);
treasureMapTilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
mMap.getOverlays().add(treasureMapTilesOverlay);
}
示例2: buildAssetTileProvider
import org.osmdroid.tileprovider.MapTileProviderArray; //导入依赖的package包/类
/**
* Build a new TileProvider that looks into the local filesystem for tiles.
*
* @param mapName The name of the map which is stored in the assets/<mapName> directory
* @return the tile provider
*/
public MapTileProviderBase buildAssetTileProvider(final String mapName) {
final NicTileSource tileSource = getTileSource(mapName);
final IRegisterReceiver registerReceiver = new SimpleRegisterReceiver(context);
final AssetTileProvider assetProvider = new AssetTileProvider(
registerReceiver, tileSource, context.getAssets()
);
final MapTileProviderArray mapTileProviderArray = new MapTileProviderArray(tileSource, registerReceiver,
new MapTileModuleProviderBase[]{
//here you can configure more than one provider...
assetProvider
});
return mapTileProviderArray;
}
示例3: buildWebTileProvider
import org.osmdroid.tileprovider.MapTileProviderArray; //导入依赖的package包/类
/**
* Build a new TileProvider that download the tiles from a server. These tiles
* will be stored (cached) in the local file system.
*
* @param urlSchema the url schema for the map tiles
* @param mapName The name of the requested map.
* @return the tile provider
*/
public MapTileProviderBase buildWebTileProvider(final String urlSchema, final String mapName) {
final ITileSource tileSource = getNicTileSource(urlSchema, mapName);
final MapTileDownloader downloaderProvider = getMapTileDownloader(tileSource);
final IRegisterReceiver registerReceiver = new SimpleRegisterReceiver(context);
final MapTileFilesystemProvider fileSystemProvider =
new MapTileFilesystemProvider(registerReceiver, tileSource);
final MapTileProviderArray mapTileProviderArray = new MapTileProviderArray(tileSource, registerReceiver,
new MapTileModuleProviderBase[]{
fileSystemProvider, //erst wird der cache verwendet
downloaderProvider //...und wenn es nötig ist im netz
});
return mapTileProviderArray;
}
示例4: addOverlays
import org.osmdroid.tileprovider.MapTileProviderArray; //导入依赖的package包/类
@Override
public void addOverlays() {
this.mMapView.setUseDataConnection(false);
MapTileAssetsProvider prov = new MapTileAssetsProvider(new SimpleRegisterReceiver(getContext() ), getActivity().getAssets());
this.mMapView.setTileProvider(new MapTileProviderArray(TileSourceFactory.MAPNIK, new SimpleRegisterReceiver(getContext()), new MapTileModuleProviderBase[]{ prov }));
}
示例5: addOverlays
import org.osmdroid.tileprovider.MapTileProviderArray; //导入依赖的package包/类
@Override
public void addOverlays() {
mMapView.setUseDataConnection(false);
final ScaleBarOverlay scaleBarOverlay = new ScaleBarOverlay(mMapView);
scaleBarOverlay.setCentred(true);
scaleBarOverlay.setScaleBarOffset(200, 10);
mMapView.getOverlays().add(scaleBarOverlay);
final ITileSource tileSource = new XYTileSource(
"Abstract", 0, 29, 256, ".png", new String[]{"http://localhost/"}, "abstract data");
mMapView.setUseDataConnection(false);
final MapTileAssetsProvider assetsProvider = new MapTileAssetsProvider(new SimpleRegisterReceiver(getContext()), getActivity().getAssets(), tileSource);
final MapTileApproximater approximationProvider = new MapTileApproximater();
approximationProvider.addProvider(assetsProvider);
final MapTileProviderArray array = new MapTileProviderArray(
tileSource, new SimpleRegisterReceiver(getContext()),
new MapTileModuleProviderBase[]{assetsProvider, approximationProvider});
mMapView.setTileProvider(array);
mMapView.getController().setZoom(29.);
// cf. https://fr.wikipedia.org/wiki/Point_z%C3%A9ro_des_routes_de_France
// In English: starting point of all French roads
mMapView.setExpectedCenter(new GeoPoint(48.85340215825712, 2.348784611094743));
mMapView.invalidate();
}
示例6: createMapOBSO
import org.osmdroid.tileprovider.MapTileProviderArray; //导入依赖的package包/类
private void createMapOBSO() {
final Context context = this;
final Context applicationContext = context.getApplicationContext();
final IRegisterReceiver registerReceiver = new SimpleRegisterReceiver(applicationContext);
// Create a custom tile source
final ITileSource tileSource = new XYTileSource("Mapnik", ResourceProxy.string.mapnik, 1, 18, 256, ".png", "http://tile.openstreetmap.org/");
// Create a file cache modular provider
final TileWriter tileWriter = new TileWriter();
final MapTileFilesystemProvider fileSystemProvider = new MapTileFilesystemProvider(registerReceiver, tileSource);
// Create an archive file modular tile provider
//GEMFFileArchive gemfFileArchive = GEMFFileArchive.getGEMFFileArchive(mGemfArchiveFilename ); // Requires try/catch
//MapTileFileArchiveProvider fileArchiveProvider = new MapTileFileArchiveProvider(registerReceiver, tileSource, new IArchiveFile[] { gemfFileArchive });
// Create a download modular tile provider
final NetworkAvailabliltyCheck networkAvailabliltyCheck = new NetworkAvailabliltyCheck(context);
final MapTileDownloader downloaderProvider = new MapTileDownloader(tileSource, tileWriter, networkAvailabliltyCheck);
// Create a custom tile provider array with the custom tile source and the custom tile providers
//final MapTileProviderArray tileProviderArray = new MapTileProviderArray(tileSource, registerReceiver, new MapTileModuleProviderBase[] { fileSystemProvider, fileArchiveProvider, downloaderProvider });
final MapTileProviderArray tileProviderArray = new MapTileProviderArray(tileSource, registerReceiver, new MapTileModuleProviderBase[] { fileSystemProvider, downloaderProvider });
//final MapTileProviderArray tileProviderArray = new MapTileProviderArray(tileSource, registerReceiver, new MapTileModuleProviderBase[] { downloaderProvider });
// Create the mapview with the custom tile provider array
//mMapView = new MapView(context, 256, new DefaultResourceProxyImpl(context), tileProviderArray);
MapView mMapView = (MapView) findViewById(R.id.mapview);
mMapView.setTileSource(tileSource);
}
示例7: onCreate
import org.osmdroid.tileprovider.MapTileProviderArray; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AndroidGraphicFactory.createInstance(this.getApplication());
try {
ResourceProxy resourceProxy = new DefaultResourceProxyImpl(this);
// Create a custom tile source
final ITileSource tileSource = new MFTileSource(8,20, 256,
Environment.getExternalStorageDirectory() + "/DolphinLocationApp"
+ "/Mapsforge/map/iran.map",
Environment.getExternalStorageDirectory() + "/DolphinLocationApp"
+ "/Mapsforge/renderthemes/detailed.xml"
, this);
//
final IRegisterReceiver registerReceiver = new SimpleRegisterReceiver(this);
MFTileModuleProvider moduleProvider;
moduleProvider = new MFTileModuleProvider(this, new File(""), (MFTileSource)tileSource);
MapTileModuleProviderBase[] pTileProviderArray;
pTileProviderArray = new MapTileModuleProviderBase[] { moduleProvider};
final MapTileProviderArray tileProviderArray = new MapTileProviderArray(
tileSource, registerReceiver, pTileProviderArray);
mapView = new MFMapView(this, tileProviderArray.getTileSource().getTileSizePixels(),
resourceProxy, tileProviderArray);
mapView.setBuiltInZoomControls(false);
mapView.setMultiTouchControls(true);
final LinearLayout mapLinearLayout = (LinearLayout) this.findViewById(R.id.mapLinearLayout);
mapLinearLayout.addView(mapView);
mapView.setCurrentAsCenter();
mapView.addMyLocationOverlay();
mapView.setBuiltInZoomControls(true);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}