当前位置: 首页>>代码示例>>Java>>正文


Java MapPosition类代码示例

本文整理汇总了Java中org.mapsforge.core.model.MapPosition的典型用法代码示例。如果您正苦于以下问题:Java MapPosition类的具体用法?Java MapPosition怎么用?Java MapPosition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MapPosition类属于org.mapsforge.core.model包,在下文中一共展示了MapPosition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCenterForMapsforgeFile

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
public MapPosition getCenterForMapsforgeFile(final String filePath){
	
	final File file = new File(filePath);
	Log.i(SupportedType.class.getSimpleName(), "Map file is " + file.getAbsolutePath()+ " file exists "+Boolean.toString(file.exists()));
	final String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
	MapDatabase mapDatabase = new MapDatabase();
	final FileOpenResult result = mapDatabase.openFile(file);
	if (result.isSuccess()) {
		final MapFileInfo mapFileInfo = mapDatabase.getMapFileInfo();
		if (mapFileInfo != null && mapFileInfo.startPosition != null) {
			return new MapPosition(mapFileInfo.startPosition, mapFileInfo.startZoomLevel != null ? mapFileInfo.startZoomLevel : 8);
		} else if(mapFileInfo != null){
			final LatLong center  = mapFileInfo.boundingBox.getCenterPoint();
			if(center != null){
				return new MapPosition(center, mapFileInfo.startZoomLevel != null ? mapFileInfo.startZoomLevel : 8);
			}else{
				Log.e(SupportedType.class.getSimpleName(), "could not retrieve bounding box center position for "+fileName);
			}
		}else{
			Log.e(SupportedType.class.getSimpleName(), "could not retrieve map start position for "+fileName);
			return new MapPosition(new LatLong(0,0),(byte) 8);
		}
	}
	throw new IllegalArgumentException("Invalid Map File " + fileName); 
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:26,代码来源:MainActivity.java

示例2: fromPixels

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
@Override
public GeoPoint fromPixels(int x, int y) {
	if (this.mapView.getWidth() <= 0 || this.mapView.getHeight() <= 0) {
		return null;
	}

	MapPosition mapPosition = this.mapView.getMapViewPosition().getMapPosition();

	// calculate the pixel coordinates of the top left corner
	GeoPoint geoPoint = mapPosition.geoPoint;
	double pixelX = MercatorProjection.longitudeToPixelX(geoPoint.longitude, mapPosition.zoomLevel);
	double pixelY = MercatorProjection.latitudeToPixelY(geoPoint.latitude, mapPosition.zoomLevel);
	pixelX -= this.mapView.getWidth() >> 1;
	pixelY -= this.mapView.getHeight() >> 1;

	// convert the pixel coordinates to a GeoPoint and return it
	return new GeoPoint(MercatorProjection.pixelYToLatitude(pixelY + y, mapPosition.zoomLevel),
			MercatorProjection.pixelXToLongitude(pixelX + x, mapPosition.zoomLevel));
}
 
开发者ID:DonTomika,项目名称:mapsforge,代码行数:20,代码来源:MapViewProjection.java

示例3: restoreMapView

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
private void restoreMapView(MapView mapView) {
	SharedPreferences sharedPreferences = getSharedPreferences(PREFERENCES_FILE, MODE_PRIVATE);

	if (isCompatible(sharedPreferences) && containsMapViewPosition(sharedPreferences)) {
		if (sharedPreferences.contains(KEY_MAP_FILE)) {
			// get and set the map file
			mapView.setMapFile(new File(sharedPreferences.getString(KEY_MAP_FILE, null)));
		}

		// get and set the map position and zoom level
		float latitude = sharedPreferences.getFloat(KEY_LATITUDE, 0);
		float longitude = sharedPreferences.getFloat(KEY_LONGITUDE, 0);
		int zoomLevel = sharedPreferences.getInt(KEY_ZOOM_LEVEL, -1);

		GeoPoint geoPoint = new GeoPoint(latitude, longitude);
		MapPosition mapPosition = new MapPosition(geoPoint, (byte) zoomLevel);
		mapView.getMapViewPosition().setMapPosition(mapPosition);
	}
}
 
开发者ID:DonTomika,项目名称:mapsforge,代码行数:20,代码来源:MapActivity.java

示例4: redraw

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
private void redraw() {
	if (this.overlayCanvas == null) {
		this.overlayCanvas = new Canvas();
	}
	this.bitmap2.eraseColor(Color.TRANSPARENT);
	this.overlayCanvas.setBitmap(this.bitmap2);

	MapPosition mapPositionBefore = this.mapView.getMapViewPosition().getMapPosition();
	BoundingBox boundingBox = this.mapView.getMapViewPosition().getBoundingBox();
	List<Overlay> overlays = this.mapView.getOverlays();
	synchronized (overlays) {
		for (Overlay overlay : overlays) {
			overlay.draw(boundingBox, mapPositionBefore.zoomLevel, this.overlayCanvas);
		}
	}

	MapPosition mapPositionAfter = this.mapView.getMapViewPosition().getMapPosition();
	synchronized (this.matrix) {
		adjustMatrix(mapPositionBefore, mapPositionAfter);
		swapBitmaps();
	}

	this.mapView.postInvalidate();
}
 
开发者ID:DonTomika,项目名称:mapsforge,代码行数:25,代码来源:OverlayController.java

示例5: isRedrawNecessary

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
private boolean isRedrawNecessary() {
	if (this.redrawNeeded || this.mapPosition == null) {
		return true;
	}

	MapPosition currentMapPosition = this.mapView.getMapViewPosition().getMapPosition();

	if (currentMapPosition.zoomLevel != this.mapPosition.zoomLevel) {
		return true;
	}

	double latitudeDiff = Math.abs(currentMapPosition.geoPoint.latitude - this.mapPosition.geoPoint.latitude);
	if (latitudeDiff > LATITUDE_REDRAW_THRESHOLD) {
		return true;
	}

	return false;
}
 
开发者ID:DonTomika,项目名称:mapsforge,代码行数:19,代码来源:MapScaleBar.java

示例6: getInitialPosition

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
private MapPosition getInitialPosition() {
    File mapFile = getMapFile();
    MapDataStore mapDataStore = new MapFile(mapFile);

    final LatLong uniteich = new LatLong(48.33706, 14.31960);
    final byte zoomLevel = (byte) Math.max(Math.min(DEFAULT_ZOOM_LEVEL /*mapDataStore.startZoomLevel()*/, MAX_ZOOM_LEVEL), MIN_ZOOM_LEVEL);

    if (mapDataStore.boundingBox().contains(uniteich)) {
        // Insel im Uniteich
        return new MapPosition(uniteich, zoomLevel);
    } else if (mapDataStore.startPosition() != null &&
            mapDataStore.boundingBox().contains(mapDataStore.startPosition())) {
        // given start position, zoom in range
        return new MapPosition(mapDataStore.startPosition(), zoomLevel);
    } else {
        // center of the map
        return new MapPosition(
                mapDataStore.boundingBox().getCenterPoint(),
                zoomLevel);
    }
}
 
开发者ID:marunjar,项目名称:anewjkuapp,代码行数:22,代码来源:MapFragment.java

示例7: fromPixels

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
public GeoPoint fromPixels( int x, int y ) {
    if (this.view.getWidth() <= 0 || this.view.getHeight() <= 0) {
        return null;
    }

    MapPosition mapPosition = this.mapView.getMapPosition().getMapPosition();

    // calculate the pixel coordinates of the top left corner
    GeoPoint geoPoint = mapPosition.geoPoint;
    double pixelX = MercatorProjection.longitudeToPixelX(geoPoint.getLongitude(), mapPosition.zoomLevel);
    double pixelY = MercatorProjection.latitudeToPixelY(geoPoint.getLatitude(), mapPosition.zoomLevel);
    pixelX -= this.view.getWidth() >> 1;
    pixelY -= this.view.getHeight() >> 1;

    // convert the pixel coordinates to a GeoPoint and return it
    double lat = MercatorProjection.pixelYToLatitude(pixelY + y, mapPosition.zoomLevel);
    double lon = MercatorProjection.pixelXToLongitude(pixelX + x, mapPosition.zoomLevel);

    if (lat < -90 || lat > 90) {
        return new GeoPoint(0, 0);
    }
    if (lon < -180 || lon > 180) {
        return new GeoPoint(0, 0);
    }
    return new GeoPoint(lat, lon);
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:27,代码来源:SliderDrawProjection.java

示例8: toPixels

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
public Point toPixels( GeoPoint in, Point out ) {
    if (this.view.getWidth() <= 0 || this.view.getHeight() <= 0) {
        return null;
    }

    MapPosition mapPosition = this.mapView.getMapPosition().getMapPosition();

    // calculate the pixel coordinates of the top left corner
    GeoPoint geoPoint = mapPosition.geoPoint;
    double pixelX = MercatorProjection.longitudeToPixelX(geoPoint.getLongitude(), mapPosition.zoomLevel);
    double pixelY = MercatorProjection.latitudeToPixelY(geoPoint.getLatitude(), mapPosition.zoomLevel);
    pixelX -= this.view.getWidth() >> 1;
    pixelY -= this.view.getHeight() >> 1;

    if (out == null) {
        // create a new point and return it
        return new Point((int) (MercatorProjection.longitudeToPixelX(in.getLongitude(), mapPosition.zoomLevel) - pixelX),
                (int) (MercatorProjection.latitudeToPixelY(in.getLatitude(), mapPosition.zoomLevel) - pixelY));
    }

    // reuse the existing point
    out.x = (int) (MercatorProjection.longitudeToPixelX(in.getLongitude(), mapPosition.zoomLevel) - pixelX);
    out.y = (int) (MercatorProjection.latitudeToPixelY(in.getLatitude(), mapPosition.zoomLevel) - pixelY);
    return out;
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:26,代码来源:SliderDrawProjection.java

示例9: getInitialPosition

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
protected MapPosition getInitialPosition() {
	MapDatabase mapDatabase = new MapDatabase();
	final FileOpenResult result = mapDatabase.openFile(getMapFile());
	if (result.isSuccess()) {
		final MapFileInfo mapFileInfo = mapDatabase.getMapFileInfo();
		if (mapFileInfo != null && mapFileInfo.startPosition != null) {
			return new MapPosition(mapFileInfo.startPosition,
					(byte) mapFileInfo.startZoomLevel);
		} else {
			return new MapPosition(new LatLong(27.517037, 85.38886),
					(byte) 12);
		}
	}
	throw new IllegalArgumentException("Invalid Map File "
			+ getMapFileName());
}
 
开发者ID:nirabpudasaini,项目名称:Mero-Bhada-Meter,代码行数:17,代码来源:OfflineMapActivity.java

示例10: centerPointOnMap

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
/**
 * center the LatLong point in the map and zoom map to zoomLevel
 *
 * @param latLong
 * @param zoomLevel (if 0 use current zoomlevel)
 */
public void centerPointOnMap(LatLong latLong, int zoomLevel) {
    if (zoomLevel == 0) {
        mapView.getModel().mapViewPosition
                .setMapPosition(new MapPosition(latLong, mapView.getModel().mapViewPosition.getZoomLevel()));
    } else {mapView.getModel().mapViewPosition.setMapPosition(new MapPosition(latLong, (byte) zoomLevel));}
}
 
开发者ID:junjunguo,项目名称:PocketMaps,代码行数:13,代码来源:MapHandler.java

示例11: setMapPosition

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
public void setMapPosition(BoundingBox _bbox) {
	byte zoomLevel = LatLongUtils.zoomForBounds(
			getModel().mapViewDimension.getDimension(), _bbox,
			getModel().displayModel.getTileSize());
	getModel().mapViewPosition.setMapPosition(new MapPosition(_bbox
			.getCenterPoint(), zoomLevel));
}
 
开发者ID:ianmalcolm,项目名称:DeadReckoning,代码行数:8,代码来源:MapView.java

示例12: onStart

import org.mapsforge.core.model.MapPosition; //导入依赖的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);
}
 
开发者ID:lienching,项目名称:MapsforgeSample,代码行数:14,代码来源:SimpleMapView.java

示例13: toPixels

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
@Override
public Point toPixels(GeoPoint in, Point out) {
	if (this.mapView.getWidth() <= 0 || this.mapView.getHeight() <= 0) {
		return null;
	}

	MapPosition mapPosition = this.mapView.getMapViewPosition().getMapPosition();

	// calculate the pixel coordinates of the top left corner
	GeoPoint geoPoint = mapPosition.geoPoint;
	double pixelX = MercatorProjection.longitudeToPixelX(geoPoint.longitude, mapPosition.zoomLevel);
	double pixelY = MercatorProjection.latitudeToPixelY(geoPoint.latitude, mapPosition.zoomLevel);
	pixelX -= this.mapView.getWidth() >> 1;
	pixelY -= this.mapView.getHeight() >> 1;

	if (out == null) {
		// create a new point and return it
		return new Point(
				(int) (MercatorProjection.longitudeToPixelX(in.longitude, mapPosition.zoomLevel) - pixelX),
				(int) (MercatorProjection.latitudeToPixelY(in.latitude, mapPosition.zoomLevel) - pixelY));
	}

	// reuse the existing point
	out.x = (int) (MercatorProjection.longitudeToPixelX(in.longitude, mapPosition.zoomLevel) - pixelX);
	out.y = (int) (MercatorProjection.latitudeToPixelY(in.latitude, mapPosition.zoomLevel) - pixelY);
	return out;
}
 
开发者ID:DonTomika,项目名称:mapsforge,代码行数:28,代码来源:MapViewProjection.java

示例14: onPause

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
@Override
protected void onPause() {
	super.onPause();

	if (this.mapViews.isEmpty()) {
		return;
	}

	for (int i = 0, n = this.mapViews.size(); i < n; ++i) {
		this.mapViews.get(i).onPause();
	}

	Editor editor = getSharedPreferences(PREFERENCES_FILE, MODE_PRIVATE).edit();
	editor.clear();
	editor.putInt(PREFERENCES_VERSION_KEY, PREFERENCES_VERSION_NUMBER);

	MapView mapView = this.mapViews.get(0);

	// save the map position and zoom level
	MapPosition mapPosition = mapView.getMapViewPosition().getMapPosition();
	GeoPoint geoPoint = mapPosition.geoPoint;
	editor.putFloat(KEY_LATITUDE, (float) geoPoint.latitude);
	editor.putFloat(KEY_LONGITUDE, (float) geoPoint.longitude);
	editor.putInt(KEY_ZOOM_LEVEL, mapPosition.zoomLevel);

	if (mapView.getMapFile() != null) {
		// save the map file
		editor.putString(KEY_MAP_FILE, mapView.getMapFile().getAbsolutePath());
	}

	editor.commit();
}
 
开发者ID:DonTomika,项目名称:mapsforge,代码行数:33,代码来源:MapActivity.java

示例15: setMapPosition

import org.mapsforge.core.model.MapPosition; //导入依赖的package包/类
/**
 * Sets the new center position and zoom level of the map without an animation.
 * 
 * @param mapPosition
 *            the new center position and zoom level of the map.
 */
public void setMapPosition(MapPosition mapPosition) {
	synchronized (this) {
		setCenterInternal(mapPosition.geoPoint);
		setZoomLevelInternal(mapPosition.zoomLevel);
	}
	this.mapView.redraw();
}
 
开发者ID:DonTomika,项目名称:mapsforge,代码行数:14,代码来源:MapViewPosition.java


注:本文中的org.mapsforge.core.model.MapPosition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。