本文整理汇总了Java中org.mapsforge.map.model.MapViewPosition类的典型用法代码示例。如果您正苦于以下问题:Java MapViewPosition类的具体用法?Java MapViewPosition怎么用?Java MapViewPosition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapViewPosition类属于org.mapsforge.map.model包,在下文中一共展示了MapViewPosition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLayers
import org.mapsforge.map.model.MapViewPosition; //导入依赖的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: createLocationLayer
import org.mapsforge.map.model.MapViewPosition; //导入依赖的package包/类
@AfterPermissionGranted(PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION)
private void createLocationLayer() {
this.mMyLocationOverlay = null;
if (EasyPermissions.hasPermissions(getContext(), Manifest.permission.ACCESS_FINE_LOCATION)) {
final Layers layers = this.mapView.getLayerManager().getLayers();
final MapViewPosition mapViewPosition = this.mapView.getModel().mapViewPosition;
// overlay with a marker to show the actual position
Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_marker_own_position);
if (drawable != null) {
Bitmap bitmap = AndroidGraphicFactory.convertToBitmap(drawable);
this.mMyLocationOverlay = new LocationOverlay(getActivity(), mapViewPosition, bitmap);
this.mMyLocationOverlay.setSnapToLocationEnabled(false);
layers.add(this.mMyLocationOverlay);
}
} else {
EasyPermissions.requestPermissions(
this,
"",
PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION);
}
}
示例3: onCreateView
import org.mapsforge.map.model.MapViewPosition; //导入依赖的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;
}
示例4: ThreeStateLocationOverlay
import org.mapsforge.map.model.MapViewPosition; //导入依赖的package包/类
/**
* Constructs a new {@code ThreeStateLocationOverlay} with the given circle paints.
*
* @param context
* a reference to the application context.
* @param mapViewPosition
* the {@code MapViewPosition} whose location will be updated.
* @param circleFill
* the {@code Paint} used to fill the circle that represents the accuracy of the current location (might be null).
* @param circleStroke
* the {@code Paint} used to stroke the circle that represents the accuracy of the current location (might be null).
*/
public ThreeStateLocationOverlay(Context context, MapViewPosition mapViewPosition, Paint circleFill,
Paint circleStroke) {
super();
this.mapViewPosition = mapViewPosition;
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
map_needle_pinned = new Marker(null, AndroidGraphicFactory.convertToBitmap(
context.getResources().getDrawable(R.drawable.map_needle_pinned)), 0, 0);
map_needle = new RotatingMarker(null, AndroidGraphicFactory.convertToBitmap(
context.getResources().getDrawable(R.drawable.map_needle)), 0, 0);
map_needle_off = new Marker(null, AndroidGraphicFactory.convertToBitmap(
context.getResources().getDrawable(R.drawable.map_needle_off)), 0, 0);
marker = map_needle_off;
showAccuracy = true;
circle = new Circle(null, 0, circleFill, circleStroke);
}
示例5: addLayers
import org.mapsforge.map.model.MapViewPosition; //导入依赖的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);
}
示例6: initializePosition
import org.mapsforge.map.model.MapViewPosition; //导入依赖的package包/类
/**
* initializes the map view position.
*
* @param mvp
* the map view position to be set
* @return the mapviewposition set
*/
protected MapViewPosition initializePosition(MapViewPosition mvp) {
LatLong center = mvp.getCenter();
if (center.equals(new LatLong(0, 0))) {
mvp.setMapPosition(this.getInitialPosition());
}
mvp.setZoomLevelMax((byte) 24);
mvp.setZoomLevelMin((byte) 7);
return mvp;
}
示例7: createTileDownloadLayer
import org.mapsforge.map.model.MapViewPosition; //导入依赖的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;
}
示例8: createTileRendererLayer
import org.mapsforge.map.model.MapViewPosition; //导入依赖的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;
}
示例9: initialize
import org.mapsforge.map.model.MapViewPosition; //导入依赖的package包/类
public static boolean initialize(String locationOfMapFile,String renderThemeAddr, Context _context) {
Log.i(TAG, "Initilizing started");
mapFilePath = locationOfMapFile;
androidGraphicFactory = AndroidGraphicFactory.INSTANCE;
mapFile = new File(mapFilePath);
displayModel = new DisplayModel();
mapViewPosition = new MapViewPosition(displayModel);
mapDataStore = new MapFile(mapFile);
displayModel.setFixedTileSize(256);
TileCache tileCache = AndroidUtil.createTileCache(context, "111", 256, 1.0f, 1d);
// TileCache tileCache = null;
databaseRenderer = new DatabaseRenderer(mapDataStore, androidGraphicFactory, tileCache);
context = _context;
try {
xmlRenderTheme = new ExternalRenderTheme(new File(renderThemeAddr ));
Log.i(TAG, "xmlRenderTheme initialized successfully");
}
catch(Throwable e)
{
Log.i(TAG, "xmlRenderTheme error initializing ");
e.printStackTrace();
}
renderThemeFuture = new RenderThemeFuture(AndroidGraphicFactory.INSTANCE, xmlRenderTheme, displayModel);
new Thread(renderThemeFuture).run();
Log.i(TAG, "Mapsforge Initializing Ended");
return true;
}
示例10: createTileRendererLayer
import org.mapsforge.map.model.MapViewPosition; //导入依赖的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;
}
示例11: MyLocationOverlay
import org.mapsforge.map.model.MapViewPosition; //导入依赖的package包/类
/**
* Constructs a new {@code MyLocationOverlay} with the given circle paints.
*
* @param activity a reference to the activity.
* @param mapViewPosition the {@code MapViewPosition} whose location will be updated.
* @param bitmap a bitmap to display at the current location (might be null).
* @param circleFill the {@code Paint} used to fill the circle that represents the accuracy of the current location (might be null).
* @param circleStroke the {@code Paint} used to stroke the circle that represents the accuracy of the current location (might be null).
*/
public MyLocationOverlay(Activity activity, MapViewPosition mapViewPosition, Bitmap bitmap, Paint circleFill,
Paint circleStroke) {
super();
this.activity = activity;
this.mapViewPosition = mapViewPosition;
this.locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
this.marker = new Marker(null, bitmap, 0, 0);
this.circle = new Circle(null, 0, circleFill, circleStroke);
}
示例12: createTileRendererLayer
import org.mapsforge.map.model.MapViewPosition; //导入依赖的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: initializePosition
import org.mapsforge.map.model.MapViewPosition; //导入依赖的package包/类
private MapViewPosition initializePosition(MapViewPosition mvp) {
LatLong center = mvp.getCenter();
if (center.equals(new LatLong(0, 0))) {
mvp.setMapPosition(this.getInitialPosition());
}
return mvp;
}
示例14: LocationOverlay
import org.mapsforge.map.model.MapViewPosition; //导入依赖的package包/类
public LocationOverlay(Activity activity, MapViewPosition mapViewPosition,
Bitmap bitmap, Paint circleFill, Paint circleStroke) {
super(activity, mapViewPosition, bitmap, circleFill, circleStroke);
this.mContext = activity;
}
示例15: createTileRendererLayer
import org.mapsforge.map.model.MapViewPosition; //导入依赖的package包/类
static Layer createTileRendererLayer(TileCache tileCache, MapViewPosition mapViewPosition, File mapFile) {
TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapViewPosition,
false, false, AndroidGraphicFactory.INSTANCE);
tileRendererLayer.setMapFile(mapFile);
tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
tileRendererLayer.setTextScale(1.5f);
return tileRendererLayer;
}