本文整理汇总了Java中org.mapsforge.map.layer.Layer类的典型用法代码示例。如果您正苦于以下问题:Java Layer类的具体用法?Java Layer怎么用?Java Layer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Layer类属于org.mapsforge.map.layer包,在下文中一共展示了Layer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import org.mapsforge.map.layer.Layer; //导入依赖的package包/类
@Override
public final void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
// get shared preferences
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
// Register our gps broadcast mReceiver
registerReceiver();
catalogObjects = new ArrayList<Layer>();
sessionObjects = new ArrayList<Layer>();
gpxObjects = new Polyline(MapUtils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.BLACK), STROKE_GPX_WIDTH,
Style.STROKE), AndroidGraphicFactory.INSTANCE);
}
示例2: destroyAll
import org.mapsforge.map.layer.Layer; //导入依赖的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();
}
示例3: clearSessionLayer
import org.mapsforge.map.layer.Layer; //导入依赖的package包/类
/**
*
*/
private void clearSessionLayer() {
if (mSessionObjects == null) {
return;
}
if (mMapView == null) {
mSessionObjects = null;
return;
}
for (final Iterator<Layer> iterator = mSessionObjects.iterator(); iterator.hasNext(); ) {
final Layer layer = iterator.next();
this.mMapView.getLayerManager().getLayers().remove(layer);
}
mSessionObjects.clear();
}
示例4: clearCatalogLayer
import org.mapsforge.map.layer.Layer; //导入依赖的package包/类
/**
* Clears catalog layer objects
*/
private void clearCatalogLayer() {
if (mCatalogObjects == null) {
return;
}
if (mMapView == null) {
mCatalogObjects = null;
return;
}
synchronized (mCatalogObjects) {
for (final Iterator<Layer> iterator = mCatalogObjects.iterator(); iterator.hasNext(); ) {
final Layer layer = iterator.next();
this.mMapView.getLayerManager().getLayers().remove(layer);
}
mCatalogObjects.clear();
}
}
示例5: addOfflineLayer
import org.mapsforge.map.layer.Layer; //导入依赖的package包/类
private void addOfflineLayer() {
final Layer offlineLayer = MapUtils.createTileRendererLayer(
this.mTileCache,
this.mMapView.getModel().mapViewPosition,
MapUtils.getMapFile(this.getActivity()),
MapUtils.getRenderTheme(this.getActivity()),null);
if (offlineLayer != null) this.mMapView.getLayerManager().getLayers().add(offlineLayer);
}
示例6: addLayers
import org.mapsforge.map.layer.Layer; //导入依赖的package包/类
protected void addLayers(TileCache tileCache, MapViewPosition mapViewPosition) {
if (isNetworkAvailable()) {
downloadLayer = new TileDownloadLayer(this.tileCache,
mapViewPosition, OpenStreetMapMapnik.INSTANCE,
AndroidGraphicFactory.INSTANCE);
layerManager.getLayers().add(downloadLayer);
} else {
Layer layer = Utils.createTileRendererLayer(tileCache, mapViewPosition, getMapFile());
layerManager.getLayers().add(layer);
}
// a marker to show at the position
Drawable drawable = getResources().getDrawable(R.drawable.pin);
Bitmap bitmap = AndroidGraphicFactory.convertToBitmap(drawable);
// create the overlay and tell it to follow the location
myLocationOverlay = new MyLocationOverlay(this,
mapViewPosition, bitmap, Utils.createPaint(AndroidGraphicFactory.INSTANCE.createColor(90, 15, 20, 25), 0,
Style.FILL), null, user);
myLocationOverlay.setSnapToLocationEnabled(false);
layerManager.getLayers().add(this.myLocationOverlay);
}
示例7: destroyLayers
import org.mapsforge.map.layer.Layer; //导入依赖的package包/类
/**
* Destroys layers and associated tile caches for the map view.
*
* @param destroyOverlays Whether to destroy overlays (markers and circles) or just the tile layers
*/
private void destroyLayers(boolean destroyOverlays) {
Layers layers = null;
if (mapMap != null)
layers = mapMap.getLayerManager().getLayers();
if (mapDownloadLayer != null) {
if (layers != null)
layers.remove(mapDownloadLayer);
mapDownloadLayer.onDestroy();
mapDownloadLayer = null;
}
if (mapRendererLayer != null) {
if (layers != null)
layers.remove(mapRendererLayer);
mapRendererLayer.onDestroy();
mapRendererLayer = null;
}
if (mapDownloadTileCache != null) {
mapDownloadTileCache.destroy();
mapDownloadTileCache = null;
}
if (mapRendererTileCache != null) {
mapRendererTileCache.destroy();
mapRendererTileCache = null;
}
if (destroyOverlays && (layers != null))
for (Layer layer : layers) {
layer.onDestroy();
layers.remove(layer);
}
}
示例8: reloadTheme
import org.mapsforge.map.layer.Layer; //导入依赖的package包/类
public void reloadTheme(String newTheme) {
if (!newTheme.equals(mCurrentTheme) && mReady) {
try {
Layer oldLayer = mTileLayer;
mTileLayer = loadThemeLayer(newTheme, false);
getLayerManager().getLayers().remove(oldLayer);
getLayerManager().getLayers().add(0, mTileLayer);
mCurrentTheme = newTheme;
} catch(IOException ex) {
Log.e(TAG, ex.getMessage());
}
}
}
示例9: clearSessionLayer
import org.mapsforge.map.layer.Layer; //导入依赖的package包/类
/**
*
*/
private void clearSessionLayer() {
for (final Iterator<Layer> iterator = sessionObjects.iterator(); iterator.hasNext();) {
final Layer layer = (Layer) iterator.next();
this.mMapView.getLayerManager().getLayers().remove(layer);
}
sessionObjects.clear();
}
示例10: clearCatalogLayer
import org.mapsforge.map.layer.Layer; //导入依赖的package包/类
/**
* Clears catalog layer objects
*/
private void clearCatalogLayer() {
synchronized (catalogObjects) {
for (final Iterator<Layer> iterator = catalogObjects.iterator(); iterator.hasNext();) {
final Layer layer = (Layer) iterator.next();
this.mMapView.getLayerManager().getLayers().remove(layer);
}
catalogObjects.clear();
}
}
示例11: createTileDownloadLayer
import org.mapsforge.map.layer.Layer; //导入依赖的package包/类
@SuppressWarnings("unused")
private Layer createTileDownloadLayer(TileCache tileCache,
MapViewPosition mapViewPosition) {
TileSource tileSource = OpenStreetMapMapnik.INSTANCE;
TileDownloadLayer tileDownloadLayer = new TileDownloadLayer(tileCache,
mapViewPosition, tileSource, GRAPHIC_FACTORY);
tileDownloadLayer.start();
return tileDownloadLayer;
}
示例12: onPause
import org.mapsforge.map.layer.Layer; //导入依赖的package包/类
@Override
public void onPause() {
super.onPause();
if (DEBUG) Log.d(TAG, "Track.onPause");
MapView mapView = ((Tabulae) getActivity()).getMapView();
Layers layers = mapView.getLayerManager().getLayers();
for (Layer polyline: polylines) {
((AlternatingLine)polyline).getLatLongs().clear();
layers.remove(polyline, false);
}
polylines.clear();
}
示例13: createTileRendererLayer
import org.mapsforge.map.layer.Layer; //导入依赖的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;
}
示例14: addOfflineLayer
import org.mapsforge.map.layer.Layer; //导入依赖的package包/类
private void addOfflineLayer() {
final Layer offlineLayer = MapUtils.createTileRendererLayer(
this.mTileCache,
this.mMapView.getModel().mapViewPosition,
MapUtils.getMapFile(this.getActivity()),
MapUtils.getRenderTheme(this.getActivity()),null);
if (offlineLayer != null) this.mMapView.getLayerManager().getLayers().add(offlineLayer);
}
示例15: addOfflineLayer
import org.mapsforge.map.layer.Layer; //导入依赖的package包/类
/**
* Creates a long-press enabled offline map layer
*/
private void addOfflineLayer() {
final Layer offlineLayer = MapUtils.createTileRendererLayer(
this.mTileCache,
this.mMapView.getModel().mapViewPosition,
MapUtils.getMapFile(this.getActivity()),
MapUtils.getRenderTheme(this.getActivity()),
this
);
if (offlineLayer != null) this.mMapView.getLayerManager().getLayers().add(offlineLayer);
}