本文整理汇总了Java中org.mapsforge.map.android.util.AndroidUtil类的典型用法代码示例。如果您正苦于以下问题:Java AndroidUtil类的具体用法?Java AndroidUtil怎么用?Java AndroidUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AndroidUtil类属于org.mapsforge.map.android.util包,在下文中一共展示了AndroidUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLayers
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的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: onCreate
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mapView = new MapView(this);
mapView.setClickable(true);
mapView.getMapScaleBar().setVisible(true);
mapView.setBuiltInZoomControls(true);
mapView.getMapZoomControls().setZoomLevelMin((byte) 5);
mapView.getMapZoomControls().setZoomLevelMax((byte) 20);
worldMap = new MapFile(new File(Constant.PATH_WORLDMAP));
taiwanMap = new MapFile(new File(Constant.PATH_TAIWANMAP));
multiMapDataStore = new MultiMapDataStore(MultiMapDataStore.DataPolicy.RETURN_ALL);
tileCache = AndroidUtil.createTileCache(this, "mapcache", mapView.getModel().displayModel.getTileSize(), 1f, this.mapView.getModel().frameBufferModel.getOverdrawFactor());
setContentView(mapView);
}
示例3: onCreate
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
@Override public void onCreate(Bundle bundle) {
super.onCreate(bundle);
if (DEBUG) { Log.d(TAG, "Map.onCreate"); }
AndroidGraphicFactory.createInstance(getActivity().getApplication());
mapView = new MapView(getActivity());
//
mapView.setClickable(true);
mapView.getMapScaleBar().setVisible(true);
mapView.setBuiltInZoomControls(true);
mapView.getMapZoomControls().setZoomLevelMin((byte)2);
mapView.getMapZoomControls().setZoomLevelMax((byte)18);
mapView.getMapZoomControls().setShowMapZoomControls(true);
mapView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
tileCache = AndroidUtil.createTileCache(getActivity(), "mapcache", mapView.getModel().displayModel.getTileSize(),
1f, mapView.getModel().frameBufferModel.getOverdrawFactor());
polyline = new AlternatingLine(AndroidGraphicFactory.INSTANCE);
}
示例4: onCreate
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
@Override public void onCreate(Bundle bundle) {
super.onCreate(bundle);
if (DEBUG) { Log.d(TAG, "Map.onCreate"); }
AndroidGraphicFactory.createInstance(getActivity().getApplication());
mapView = new MapView(getActivity());
//
mapView.setClickable(true);
mapView.getMapScaleBar().setVisible(true);
mapView.setBuiltInZoomControls(true);
mapView.getMapZoomControls().setZoomLevelMin((byte)2);
mapView.getMapZoomControls().setZoomLevelMax((byte)18);
mapView.getMapZoomControls().setShowMapZoomControls(true);
mapView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
for (int i=0;i<tileCaches.length;i++) {
tileCaches[i]= AndroidUtil.createTileCache(getActivity(),
"mapcache-" + i, mapView.getModel().displayModel.getTileSize(), 1f,
mapView.getModel().frameBufferModel.getOverdrawFactor());
}
}
示例5: onCreate
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
@Override public void onCreate(Bundle bundle) {
super.onCreate(bundle);
if (DEBUG) { Log.d(TAG, "Map.onCreate"); }
AndroidGraphicFactory.createInstance(getActivity().getApplication());
mapView = new MapView(getActivity());
//
mapView.setClickable(true);
mapView.getMapScaleBar().setVisible(true);
mapView.setBuiltInZoomControls(true);
mapView.getMapZoomControls().setZoomLevelMin((byte)2);
mapView.getMapZoomControls().setZoomLevelMax((byte)18);
mapView.getMapZoomControls().setShowMapZoomControls(true);
mapView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
tileCache = AndroidUtil.createTileCache(getActivity(), "mapcache", mapView.getModel().displayModel.getTileSize(),
1f, mapView.getModel().frameBufferModel.getOverdrawFactor());
}
示例6: changeRenderTheme
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
void changeRenderTheme() {
File[] renderThemes = new File("/storage/sdcard1").listFiles(renderThemesFilter);
if (renderThemes.length > 0) {
File nextTheme = renderThemes[iteration % renderThemes.length];
iteration += 1;
try {
XmlRenderTheme nextRenderTheme = new ExternalRenderThemeUsingJarResources(nextTheme);
Log.i(SamplesApplication.TAG, "Loading new render theme " + nextTheme.getName());
// there should really be a simpler way to just change the
// render theme safely
mapView.getLayerManager().getLayers().remove(tileRendererLayer);
tileRendererLayer.onDestroy();
tileCaches.get(0).destroy();
tileRendererLayer = AndroidUtil.createTileRendererLayer(tileCaches.get(0),
mapView.getModel().mapViewPosition, getMapFile(), nextRenderTheme,
false, false);
mapView.getLayerManager().getLayers().add(tileRendererLayer);
mapView.getLayerManager().redrawLayers();
} catch (FileNotFoundException e) {
Log.i(SamplesApplication.TAG, "Could not open file " + nextTheme.getName());
}
}
}
示例7: onCreateView
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_item_detail,
container, false);
if (this.dummyItem != null) {
this.mapView = (MapView) rootView.findViewById(R.id.mapView);
this.mapView.setClickable(true);
this.mapView.getFpsCounter().setVisible(true);
this.mapView.getMapScaleBar().setVisible(true);
LayerManager layerManager = this.mapView.getLayerManager();
Layers layers = layerManager.getLayers();
MapViewPosition mapViewPosition = this.mapView.getModel().mapViewPosition;
mapViewPosition.setZoomLevel((byte) 16);
this.tileCache = AndroidUtil.createTileCache(this.getActivity(),
"fragments",
this.mapView.getModel().displayModel.getTileSize(), 1.0f,
1.5);
mapViewPosition.setCenter(this.dummyItem.location);
layers.add(AndroidUtil.createTileRendererLayer(this.tileCache,
mapViewPosition, getMapFile(),
InternalRenderTheme.OSMARENDER, false, true));
}
return rootView;
}
示例8: onSharedPreferenceChanged
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
super.onSharedPreferenceChanged(preferences, key);
// difficult to know which render theme options have changed since we
// do not know all the keys, so we just purge the caches and redraw
// the map whenever there is a change in the settings.
// TODO: for real applications it is essential to know when the style menu has
// changed. It would be good to find a way of identifying when a key is
// for the style menu.
Log.i(SamplesApplication.TAG, "Purging tile caches");
for (TileCache tileCache : tileCaches) {
tileCache.purge();
}
AndroidUtil.restartActivity(this);
}
示例9: setMapScaleBar
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
/**
* Sets the scale bar from preferences.
*/
protected void setMapScaleBar() {
String value = this.sharedPreferences.getString(SETTING_SCALEBAR, SETTING_SCALEBAR_BOTH);
if (SETTING_SCALEBAR_NONE.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, null, null);
} else {
if (SETTING_SCALEBAR_BOTH.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, MetricUnitAdapter.INSTANCE, ImperialUnitAdapter.INSTANCE);
} else if (SETTING_SCALEBAR_METRIC.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, MetricUnitAdapter.INSTANCE, null);
} else if (SETTING_SCALEBAR_IMPERIAL.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, ImperialUnitAdapter.INSTANCE, null);
} else if (SETTING_SCALEBAR_NAUTICAL.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, NauticalUnitAdapter.INSTANCE, null);
}
}
}
示例10: createLayers
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
@Override
protected void createLayers() {
super.createLayers();
try {
XmlRenderTheme secondRenderTheme = new AssetsRenderTheme(this, "",
"renderthemes/onlybuildings.xml", null);
this.mapView.getLayerManager()
.getLayers()
.add(AndroidUtil.createTileRendererLayer(this.tileCaches.get(1),
this.mapView.getModel().mapViewPosition, getMapFile(),
secondRenderTheme, true, false));
} catch (IOException e) {
Log.e(SamplesApplication.TAG, "Rendertheme not found");
}
}
示例11: onCreate
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (DEBUG) Log.d(TAG, "onCreate");
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable e) {
Log.e(TAG, "error e=" + e, e);
finish();
}
});
AndroidGraphicFactory.createInstance(getApplication());
mapView = new MapView(this);
setContentView(mapView);
mapView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
mapView.setClickable(true);
mapView.getMapScaleBar().setVisible(true);
mapView.setBuiltInZoomControls(true);
mapView.getMapZoomControls().setZoomLevelMin((byte)2);
mapView.getMapZoomControls().setZoomLevelMax((byte)18);
mapView.getMapZoomControls().setShowMapZoomControls(true);
// create a tile cache of suitable size
tileCache = AndroidUtil.createTileCache(this, "mapcache",
mapView.getModel().displayModel.getTileSize(), 1f,
mapView.getModel().frameBufferModel.getOverdrawFactor());
}
示例12: onCreate
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
@Override public void onCreate(Bundle bundle) {
super.onCreate(bundle);
if (DEBUG) { Log.d(TAG, "Map.onCreate"); }
AndroidGraphicFactory.createInstance(getActivity().getApplication());
mapView = new MapView(getActivity());
//
mapView.setClickable(true);
AndroidUtil.setMapScaleBar(mapView, MetricUnitAdapter.INSTANCE, null);
mapView.getMapScaleBar().setVisible(true);
mapView.setBuiltInZoomControls(true);
mapView.getMapZoomControls().setZoomLevelMin((byte)2);
mapView.getMapZoomControls().setZoomLevelMax((byte)18);
mapView.getMapZoomControls().setShowMapZoomControls(true);
mapView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
DisplayModel displayModel = mapView.getModel().displayModel;
displayModel.setBackgroundColor(0xffff0000); // red background, defaults to 0xffeeeeee
displayModel.setFixedTileSize(512); // change the tile size, defaults to 256
// displayModel.setMaxTextWidthFactor(0.3f); // defaults to .7f
// displayModel.setTileSizeMultiple(100); // defaults to 64
displayModel.setUserScaleFactor(1.5f); // scaled map, defaults to 1.0f
tileCache = AndroidUtil.createTileCache(getActivity(), "mapcache", mapView.getModel().displayModel.getTileSize(),
1f, mapView.getModel().frameBufferModel.getOverdrawFactor());
}
示例13: onCreateView
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rvalue = inflater.inflate(R.layout.fragment_map, container, false);
tileCache = AndroidUtil.createTileCache(getActivity(), MapsConfig.TILE_CACHE_ID, MapsConfig.TILE_SIZE, MapsConfig.SCREEN_RATION, MapsConfig.OVERDRAW);
final File mapFile = AbstractMap.instance().getMapsforgeFile(getActivity());
mMapView = new MapsforgeMapView(getActivity(), tileCache, mapFile.getAbsolutePath());
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
RelativeLayout forMap = (RelativeLayout) rvalue.findViewById(R.id.layout_map);
forMap.addView(mMapView, 0, params);
buildGoogleApiClient();
return rvalue;
}
示例14: onCreateView
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rvalue = inflater.inflate(R.layout.fragment_map, container, false);
tileCache = AndroidUtil.createTileCache(getActivity(), MapsConfig.TILE_CACHE_ID, MapsConfig.TILE_SIZE, MapsConfig.SCREEN_RATION, MapsConfig.OVERDRAW);
final File mapFile = AbstractMap.instance().getMapsforgeFile(getActivity());
mMapView = new MapsforgeMapView(getActivity(), tileCache, mapFile.getAbsolutePath());
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
RelativeLayout forMap = (RelativeLayout) rvalue.findViewById(R.id.layout_map);
forMap.addView(mMapView, 0, params);
return rvalue;
}
示例15: init
import org.mapsforge.map.android.util.AndroidUtil; //导入依赖的package包/类
public void init(Activity activity, MapView mapView, String currentArea, File mapsFolder) {
this.activity = activity;
this.mapView = mapView;
this.currentArea = currentArea;
this.mapsFolder = mapsFolder;
// this.prepareInProgress = prepareInProgress;
tileCache = AndroidUtil
.createTileCache(activity, getClass().getSimpleName(), mapView.getModel().displayModel.getTileSize(),
1f, mapView.getModel().frameBufferModel.getOverdrawFactor());
}