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


Java MapView类代码示例

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


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

示例1: initMap

import org.mapsforge.map.android.view.MapView; //导入依赖的package包/类
private void initMap() {
    AndroidGraphicFactory.createInstance(getApplication());
    mapView = new MapView(this);

    mapView.setClickable(true);
    mapView.getMapScaleBar().setVisible(false);
    mapView.setBuiltInZoomControls(false);
    mapView.setZoomLevelMin((byte) 2);
    mapView.setZoomLevelMax((byte) 10);

    mapView.setZoomLevel((byte) 2);
    mapView.getModel().displayModel.setBackgroundColor(ContextCompat.getColor(this, R.color.mapBackground));

    layers = mapView.getLayerManager().getLayers();

    MapCreator mapCreator = new MapCreator(this, layers);
    mapCreator.parseGeoJson("world_map.geo.json");

    initServerOnMap(layers);

    LinearLayout map = (LinearLayout) findViewById(R.id.map);
    map.addView(mapView);
}
 
开发者ID:MaxSmile,项目名称:EasyVPN-Free,代码行数:24,代码来源:HomeActivity.java

示例2: showMyLocation

import org.mapsforge.map.android.view.MapView; //导入依赖的package包/类
/**
 * move map to my current location as the center of the screen
 */
protected void showMyLocation(final MapView mapView) {
    showPositionBtn.setOnClickListener(new View.OnClickListener() {
        @Override public void onClick(View v) {
            if (MapActivity.getmCurrentLocation() != null) {
                showPositionBtn.setImageResource(R.drawable.ic_my_location_white_24dp);
                MapHandler.getMapHandler().centerPointOnMap(
                        new LatLong(MapActivity.getmCurrentLocation().getLatitude(),
                                MapActivity.getmCurrentLocation().getLongitude()), 0);

                //                    mapView.getModel().mapViewPosition.setMapPosition(new MapPosition(
                //                            new LatLong(MapActivity.getmCurrentLocation().getLatitude(),
                //                                    MapActivity.getmCurrentLocation().getLongitude()),
                //                            mapView.getModel().mapViewPosition.getZoomLevel()));

            } else {
                showPositionBtn.setImageResource(R.drawable.ic_location_searching_white_24dp);
                Toast.makeText(activity, "No Location Available", Toast.LENGTH_SHORT).show();
            }
        }
    });
}
 
开发者ID:junjunguo,项目名称:PocketMaps,代码行数:25,代码来源:MapActions.java

示例3: onCreate

import org.mapsforge.map.android.view.MapView; //导入依赖的package包/类
@Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map);
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 5, this);
    Variable.getVariable().setContext(getApplicationContext());
    Variable.getVariable().setZoomLevels(22, 1);
    AndroidGraphicFactory.createInstance(getApplication());
    mapView = new MapView(this);
    mapView.setClickable(true);
    mapView.setBuiltInZoomControls(false);
    MapHandler.getMapHandler()
            .init(this, mapView, Variable.getVariable().getCountry(), Variable.getVariable().getMapsFolder());
    MapHandler.getMapHandler().loadMap(new File(Variable.getVariable().getMapsFolder().getAbsolutePath(),
            Variable.getVariable().getCountry() + "-gh"));
    customMapView();
    checkGpsAvailability();

    getMyLastLocation();
    updateCurrentLocation(null);
}
 
开发者ID:junjunguo,项目名称:PocketMaps,代码行数:22,代码来源:MapActivity.java

示例4: onCreate

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

示例5: onCreateView

import org.mapsforge.map.android.view.MapView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_map, container, false);

    // 配置 mapView
    mMapView = (MapView)view.findViewById(R.id.mapView);
    initMapView(mMapView, getActivity());
    AndroidGraphicFactory.clearResourceMemoryCache();
    AndroidGraphicFactory.clearResourceFileCache();

    // 接收方位感應器和 GPS 訊號
    mSensorMgr = (SensorManager)getActivity().getSystemService(Context.SENSOR_SERVICE);
    mSensorMgr.registerListener(mAzimuthListener, mSensorMgr.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR), SensorManager.SENSOR_DELAY_UI);
    mLocMgr = (LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE);
    mLocMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 10.0f, mLocListener);

    // 配置訊號消化工具
    mHandler = new Handler();

    return view;
}
 
开发者ID:OsmHackTW,项目名称:AndroidMapExample,代码行数:22,代码来源:MainActivityFragment.java

示例6: onCreate

import org.mapsforge.map.android.view.MapView; //导入依赖的package包/类
@Override public void onCreate(Bundle bundle) {
	if (DEBUG) Log.d(TAG, "Map.onCreate bundle=" + bundle);
	super.onCreate(bundle);
	// AndroidGraphicFactory.createInstance(getActivity().getApplication());
	mapView = new MapView(getActivity()) {
		@Override public boolean onTouchEvent(MotionEvent motionEvent) {
			if (snapToLocationEnabled) {
				informSnapToLocation(false);
			}
			return super.onTouchEvent(motionEvent);
		}
	};
	preferences = getActivity().getSharedPreferences("map", Context.MODE_PRIVATE);
	mapView.setClickable(true);
	// TODO: consider mapView.setGestureDetector();?
	mapView.getMapScaleBar().setVisible(false);
	mapView.getModel().mapViewPosition.setZoomLevelMin((byte) 4);
	mapView.getModel().mapViewPosition.setZoomLevelMax((byte) 20);
	mapView.getModel();
	mapView.setBuiltInZoomControls(false);
	mapView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
	DisplayModel displayModel = mapView.getModel().displayModel;
	displayModel.setBackgroundColor(0xffbbbbbb);
	displayModel.setUserScaleFactor(1.5f);
}
 
开发者ID:emdete,项目名称:tabulae,代码行数:26,代码来源:Map.java

示例7: canScroll

import org.mapsforge.map.android.view.MapView; //导入依赖的package包/类
@Override
protected boolean canScroll(final View v, final boolean checkV, final int dx, final int x, final int y) {
    if (v instanceof MapView) {
    	Log.i(TAG, "Scrolling disabled for map view");
        return true;
    }
    return super.canScroll(v, checkV, dx, x, y);
}
 
开发者ID:openbmap,项目名称:radiocells-scanner-android,代码行数:9,代码来源:SelectiveScrollViewPager.java

示例8: onCreate

import org.mapsforge.map.android.view.MapView; //导入依赖的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);
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:19,代码来源:Map.java

示例9: onCreate

import org.mapsforge.map.android.view.MapView; //导入依赖的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());
	preferencesFacade = new AndroidPreferences(getActivity().getSharedPreferences("map", Context.MODE_PRIVATE));
	mapView.getModel().init(preferencesFacade);
	if (mapView.getModel().mapViewPosition.getZoomLevel() == 0) {
		// warp to 'unter den linden'
		mapView.getModel().mapViewPosition.setCenter(new LatLong(52.517037, 13.38886));
		mapView.getModel().mapViewPosition.setZoomLevel((byte)12);
	}
	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 = createExternalStorageTileCache(getActivity(), "osmarender", 50, mapView.getModel().displayModel.getTileSize());
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:25,代码来源:Map.java

示例10: onCreate

import org.mapsforge.map.android.view.MapView; //导入依赖的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());
	}
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:20,代码来源:Map.java

示例11: onCreate

import org.mapsforge.map.android.view.MapView; //导入依赖的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());
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:17,代码来源:Map.java

示例12: onCreateView

import org.mapsforge.map.android.view.MapView; //导入依赖的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;
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:32,代码来源:ItemDetailFragment.java

示例13: onCreate

import org.mapsforge.map.android.view.MapView; //导入依赖的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());
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:26,代码来源:Sample.java

示例14: onCreate

import org.mapsforge.map.android.view.MapView; //导入依赖的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());
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:24,代码来源:Map.java

示例15: onSharedPreferenceChanged

import org.mapsforge.map.android.view.MapView; //导入依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences,
		String key) {
	if (SamplesApplication.SETTING_SCALE.equals(key)) {
		destroyTileCaches();
		for (MapView mapView : mapViews) {
			mapView.getModel().displayModel.setUserScaleFactor(DisplayModel
					.getDefaultUserScaleFactor());
		}
		Log.d(SamplesApplication.TAG, "Tilesize now "
				+ mapViews.get(0).getModel().displayModel.getTileSize());
		createTileCaches();
		redrawLayers();
	}
}
 
开发者ID:nirabpudasaini,项目名称:Mero-Bhada-Meter,代码行数:16,代码来源:OfflineMapActivity.java


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