本文整理汇总了Java中org.mapsforge.map.layer.renderer.TileRendererLayer类的典型用法代码示例。如果您正苦于以下问题:Java TileRendererLayer类的具体用法?Java TileRendererLayer怎么用?Java TileRendererLayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TileRendererLayer类属于org.mapsforge.map.layer.renderer包,在下文中一共展示了TileRendererLayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLayers
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
@AfterPermissionGranted(PERMISSIONS_REQUEST_READ_STORAGE)
private void createLayers() {
if (EasyPermissions.hasPermissions(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE)) {
TileCache tileCache = AndroidUtil.createTileCache(getContext(),
"mapFragment",
this.mapView.getModel().displayModel.getTileSize(),
1.0f,
this.mapView.getModel().frameBufferModel.getOverdrawFactor());
final Layers layers = this.mapView.getLayerManager().getLayers();
final MapViewPosition mapViewPosition = this.mapView.getModel().mapViewPosition;
initializePosition(mapViewPosition);
TileRendererLayer tileRendererLayer = createTileRendererLayer(tileCache, mapViewPosition,
getMapFile(), getRenderTheme());
layers.add(tileRendererLayer);
LabelLayer labelLayer = new LabelLayer(AndroidGraphicFactory.INSTANCE, tileRendererLayer.getLabelStore());
mapView.getLayerManager().getLayers().add(labelLayer);
// overlay with a marker to show the goal position
this.goalLocationOverlay = new Marker(null, null, 0, 0);
layers.add(this.goalLocationOverlay);
createLocationLayer();
} else {
EasyPermissions.requestPermissions(
this,
"",
PERMISSIONS_REQUEST_READ_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE);
}
}
示例2: addLayers
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
private BoundingBox addLayers(MapView mapView, List<File> mapFiles) {
Layers layers = mapView.getLayerManager().getLayers();
// layers.add(createTileDownloadLayer(tileCache,
// mapView.getModel().mapViewPosition));
BoundingBox result = null;
for (int i = 0; i < mapFiles.size(); i++) {
File mapFile = mapFiles.get(i);
TileRendererLayer tileRendererLayer = createTileRendererLayer(
createTileCache(i), mapView.getModel().mapViewPosition,
true, true, mapFile);
BoundingBox boundingBox = tileRendererLayer.getMapDataStore()
.boundingBox();
result = result == null ? boundingBox : result.extend(boundingBox);
layers.add(tileRendererLayer);
}
if (SHOW_DEBUG_LAYERS) {
layers.add(new TileGridLayer(GRAPHIC_FACTORY,
mapView.getModel().displayModel));
layers.add(new TileCoordinatesLayer(GRAPHIC_FACTORY, mapView
.getModel().displayModel));
}
return result;
}
示例3: destroyAll
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
/**
* Clear all map view elements.<br/>
* i.e. layers, tile cache, label store, map view, resources, etc.
*/
@Override
public void destroyAll() {
for (Layer layer : this.layerManager.getLayers()) {
this.layerManager.getLayers().remove(layer);
layer.onDestroy();
if (layer instanceof TileLayer) {
((TileLayer<?>) layer).getTileCache().destroy();
}
if (layer instanceof TileRendererLayer) {
LabelStore labelStore = ((TileRendererLayer) layer)
.getLabelStore();
if (labelStore != null) {
labelStore.clear();
}
}
}
destroy();
AwtGraphicFactory.clearResourceMemoryCache();
}
示例4: createLayers
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
@Override
protected void createLayers() {
TileRendererLayer tileRendererLayer = new TileRendererLayer(
this.tileCaches.get(0), getMapFile(),
this.mapView.getModel().mapViewPosition,
false, true,
org.mapsforge.map.android.graphics.AndroidGraphicFactory.INSTANCE) {
@Override
public boolean onLongPress(LatLong tapLatLong, Point thisXY,
Point tapXY) {
LongPressAction.this.onLongPress(tapLatLong);
return true;
}
};
tileRendererLayer.setXmlRenderTheme(this.getRenderTheme());
mapView.getLayerManager().getLayers().add(tileRendererLayer);
BLACK.setTextSize(22);
}
示例5: onStart
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
@Override public void onStart() {
super.onStart();
if (DEBUG) { Log.d(TAG, "Map.onStart"); }
// warp to 'unter den linden'
mapView.getModel().mapViewPosition.setCenter(new LatLong(52.517037, 13.38886));
mapView.getModel().mapViewPosition.setZoomLevel((byte)12);
MultiMapDataStore multiMapDataStore = new MultiMapDataStore(MultiMapDataStore.DataPolicy.DEDUPLICATE);
tileLayer = new TileRendererLayer(tileCache, multiMapDataStore, mapView.getModel().mapViewPosition,
false, true, AndroidGraphicFactory.INSTANCE);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE1)), true, true);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE2)), false, false);
tileLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
mapView.getLayerManager().getLayers().add(tileLayer);
Bitmap bitmap = AndroidGraphicFactory.convertToBitmap(getResources().getDrawable(R.drawable.poi_black));
bitmap.incrementRefCount();
Marker marker = new Marker(new LatLong(52.517037, 13.38886), bitmap, 0, -bitmap.getHeight() / 2) {
@Override public boolean onTap(LatLong geoPoint, Point viewPosition, Point tapPoint) {
if (contains(viewPosition, tapPoint)) {
Toast.makeText(getActivity(), "Unter den Linden Ecke Friedrichstraße, Berlin", Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
};
mapView.getLayerManager().getLayers().add(marker);
}
示例6: onStart
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
@Override public void onStart() {
super.onStart();
if (DEBUG) { Log.d(TAG, "Map.onStart"); }
// warp to 'unter den linden'
mapView.getModel().mapViewPosition.setCenter(new LatLong(52.517037, 13.38886));
mapView.getModel().mapViewPosition.setZoomLevel((byte)12);
MultiMapDataStore multiMapDataStore = new MultiMapDataStore(MultiMapDataStore.DataPolicy.DEDUPLICATE);
tileLayer = new TileRendererLayer(tileCache, multiMapDataStore, mapView.getModel().mapViewPosition,
false, true, AndroidGraphicFactory.INSTANCE);
tileLayer.setTextScale(1.5f);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE1)), true, true);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE2)), false, false);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE0)), false, false);
try {
tileLayer.setXmlRenderTheme(new ExternalRenderTheme(new File(THEMEFILE))); // set a different render theme
}
catch (FileNotFoundException ignore) {
tileLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER); // fallback if not founr
}
mapView.getLayerManager().getLayers().add(tileLayer);
mapView.getLayerManager().getLayers().add( // add a grid around each tile
new TileGridLayer(AndroidGraphicFactory.INSTANCE, mapView.getModel().displayModel));
mapView.getLayerManager().getLayers().add( // add text to show x/y/z of each tile
new TileCoordinatesLayer(AndroidGraphicFactory.INSTANCE, mapView.getModel().displayModel));
}
示例7: onStart
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
@Override public void onStart() {
super.onStart();
if (DEBUG) { Log.d(TAG, "Map.onStart"); }
// warp to 'unter den linden'
mapView.getModel().mapViewPosition.setCenter(new LatLong(52.517037, 13.38886));
mapView.getModel().mapViewPosition.setZoomLevel((byte)12);
MultiMapDataStore multiMapDataStore = new MultiMapDataStore(MultiMapDataStore.DataPolicy.DEDUPLICATE);
tileLayer = new TileRendererLayer(tileCache, multiMapDataStore, mapView.getModel().mapViewPosition,
false, true, AndroidGraphicFactory.INSTANCE);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE1)), true, true);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE2)), false, false);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE0)), false, false);
tileLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
mapView.getLayerManager().getLayers().add(tileLayer);
myLocationOverlay = new ThreeStateLocationOverlay(getActivity(), mapView.getModel().mapViewPosition);
myLocationOverlay.setSnapToLocationEnabled(true);
mapView.getLayerManager().getLayers().add(myLocationOverlay);
}
示例8: loadMap
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
/**
* load map to mapView
*
* @param areaFolder
*/
public void loadMap(File areaFolder) {
logToast("Loading map: " + currentArea);
File mapFile = new File(areaFolder, currentArea + ".map");
mapView.getLayerManager().getLayers().clear();
TileRendererLayer tileRendererLayer =
new TileRendererLayer(tileCache, mapView.getModel().mapViewPosition, false, true,
AndroidGraphicFactory.INSTANCE) {
@Override public boolean onTap(LatLong tapLatLong, Point layerXY, Point tapXY) {
return myOnTap(tapLatLong, layerXY, tapXY);
}
};
tileRendererLayer.setMapFile(mapFile);
tileRendererLayer.setTextScale(0.8f);
tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
// log("last location " + Variable.getVariable().getLastLocation());
if (Variable.getVariable().getLastLocation() == null) {
centerPointOnMap(tileRendererLayer.getMapDatabase().getMapFileInfo().boundingBox.getCenterPoint(), 6);
} else {
centerPointOnMap(Variable.getVariable().getLastLocation(), Variable.getVariable().getLastZoomLevel());
}
mapView.getLayerManager().getLayers().add(tileRendererLayer);
ViewGroup.LayoutParams params =
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
activity.addContentView(mapView, params);
loadGraphStorage();
}
示例9: createTileRendererLayer
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
private TileRendererLayer createTileRendererLayer(TileCache tileCache,
MapViewPosition mapViewPosition, boolean isTransparent,
boolean renderLabels, File mapFile) {
TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache,
new MapFile(mapFile), mapViewPosition, isTransparent,
renderLabels, GRAPHIC_FACTORY);
tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
return tileRendererLayer;
}
示例10: onStart
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
@Override
protected void onStart() {
super.onStart();
multiMapDataStore.addMapDataStore(worldMap,true,true);
multiMapDataStore.addMapDataStore(taiwanMap,false,false);
//multiMapDataStore.setStartPosition(new LatLong(23, 121));
//multiMapDataStore.setStartZoomLevel((byte) 7);
tileRendererLayer = new TileRendererLayer(tileCache,multiMapDataStore,mapView.getModel().mapViewPosition,false,true, AndroidGraphicFactory.INSTANCE);
tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
mapView.getModel().mapViewPosition.setMapPosition(new MapPosition(new LatLong(23, 121), (byte) 7));
mapView.getLayerManager().getLayers().add(tileRendererLayer);
}
示例11: createTileRendererLayer
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
/**
* Creates a tile layer, which optionally supports long press actions and custom render themes
* @param tileCache
* @param mapViewPosition
* @param mapFile
* @param renderTheme
* @return
*/
public static Layer createTileRendererLayer(final TileCache tileCache, final MapViewPosition mapViewPosition,
final MapFile mapFile, final XmlRenderTheme renderTheme, final onLongPressHandler handler) {
if (mapFile == null) {
return null;
}
final TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapFile, mapViewPosition, AndroidGraphicFactory.INSTANCE) {
@Override
public boolean onLongPress(LatLong tapLatLong, Point thisXY, Point tapXY) {
if (handler != null) {
((onLongPressHandler)handler).onLongPress(tapLatLong, thisXY, tapXY);
return true;
} else {
return false;
}
}
};
if (renderTheme == null) {
Log.i(TAG, "Using default render theme");
tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
} else {
Log.i(TAG, "Using custom theme");
tileRendererLayer.setXmlRenderTheme(renderTheme);
}
tileRendererLayer.setTextScale(1.5f);
return tileRendererLayer;
}
示例12: createTileRendererLayer
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
private TileRendererLayer createTileRendererLayer(TileCache tileCache,
MapViewPosition mapViewPosition, File mapFile,
XmlRenderTheme renderTheme) {
MapDataStore mapDataStore = new MapFile(mapFile);
TileRendererLayer tileRendererLayer = AndroidUtil.createTileRendererLayer(tileCache,
mapViewPosition, mapDataStore, renderTheme, false, false, true);
tileRendererLayer.setTextScale(1.5f);
return tileRendererLayer;
}
示例13: onStart
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
@Override public void onStart() {
super.onStart();
if (DEBUG) { Log.d(TAG, "Map.onStart"); }
List<LatLong> latLongs = polyline.getLatLongs();
LatLong latLong = new LatLong(52.5, 13.4);
try {
for (TrackGpxParser.TrackPoint trackPoint : new TrackGpxParser(new File(GPXFILE))) {
latLong = trackPoint;
latLongs.add(latLong);
}
// add: mapView.getModel().mapViewPosition.setMapPosition(new MapPosition(bb.getCenterPoint(), LatLongUtils.zoomForBounds(dimension, bb, mapView.getModel().displayModel.getTileSize())));
}
catch (Exception e) {
Log.e(TAG, "Map.onStart", e);
}
// warp to track
mapView.getModel().mapViewPosition.setCenter(latLong);
mapView.getModel().mapViewPosition.setZoomLevel((byte)12);
MultiMapDataStore multiMapDataStore = new MultiMapDataStore(MultiMapDataStore.DataPolicy.DEDUPLICATE);
tileLayer = new TileRendererLayer(tileCache, multiMapDataStore, mapView.getModel().mapViewPosition,
false, true, AndroidGraphicFactory.INSTANCE);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE1)), true, true);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE2)), false, false);
tileLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
mapView.getLayerManager().getLayers().add(tileLayer);
mapView.getLayerManager().getLayers().add(polyline);
}
示例14: onStart
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
@Override
public void onStart() {
super.onStart();
if (DEBUG) {
Log.d(TAG, "Map.onStart");
}
MultiMapDataStore multiMapDataStore = new MultiMapDataStore(MultiMapDataStore.DataPolicy.DEDUPLICATE);
tileLayer = new TileRendererLayer(tileCache, multiMapDataStore, mapView.getModel().mapViewPosition,
false, true, AndroidGraphicFactory.INSTANCE);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE1)), true, true);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE2)), false, false);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE0)), false, false);
tileLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
mapView.getLayerManager().getLayers().add(tileLayer);
}
示例15: onStart
import org.mapsforge.map.layer.renderer.TileRendererLayer; //导入依赖的package包/类
@Override public void onStart() {
super.onStart();
if (DEBUG) { Log.d(TAG, "Map.onStart"); }
// warp to 'unter den linden'
mapView.getModel().mapViewPosition.setCenter(new LatLong(52.517037, 13.38886));
mapView.getModel().mapViewPosition.setZoomLevel((byte)12);
MultiMapDataStore multiMapDataStore = new MultiMapDataStore(MultiMapDataStore.DataPolicy.DEDUPLICATE);
tileLayer = new TileRendererLayer(tileCache, multiMapDataStore, mapView.getModel().mapViewPosition,
false, true, AndroidGraphicFactory.INSTANCE);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE1)), true, true);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE2)), false, false);
multiMapDataStore.addMapDataStore(new MapFile(new File(MAPFILE0)), false, false);
tileLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
mapView.getLayerManager().getLayers().add(tileLayer);
}