本文整理汇总了Java中org.osmdroid.views.overlay.ScaleBarOverlay类的典型用法代码示例。如果您正苦于以下问题:Java ScaleBarOverlay类的具体用法?Java ScaleBarOverlay怎么用?Java ScaleBarOverlay使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScaleBarOverlay类属于org.osmdroid.views.overlay包,在下文中一共展示了ScaleBarOverlay类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addOverlays
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
@Override
public void addOverlays(){
super.addOverlays();
final Context context = this.getActivity();
final DisplayMetrics dm = context.getResources().getDisplayMetrics();
ScaleBarOverlay scaleBarOverlay = new ScaleBarOverlay(mMapView);
scaleBarOverlay.setCentred(true);
//i hate this very much, but it seems as if certain versions of android and/or
//device types handle screen offsets differently
//60 on api10 is right at the bottom
//api15 and up, 85 is right at the bottom
//we are also adding 20dp padding for the overlay overlay which is added by the super class
if (Build.VERSION.SDK_INT <= 10)
scaleBarOverlay.setScaleBarOffset(dm.widthPixels / 2, dm.heightPixels - (int)(80*dm.density));
else
scaleBarOverlay.setScaleBarOffset(dm.widthPixels / 2, dm.heightPixels - (int)(105*dm.density));
scaleBarOverlay.setUnitsOfMeasure(ScaleBarOverlay.UnitsOfMeasure.imperial);
mMapView.getOverlayManager().add(scaleBarOverlay);
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:25,代码来源:ScaleBarOnBottom.java
示例2: addOverlays
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
@Override
public void addOverlays(){
super.addOverlays();
final DisplayMetrics dm = getActivity().getResources().getDisplayMetrics();
RotationGestureOverlay mRotationGestureOverlay = new RotationGestureOverlay(mMapView);
mRotationGestureOverlay.setEnabled(true);
mMapView.getOverlays().add(mRotationGestureOverlay);
ScaleBarOverlay mScaleBarOverlay = new ScaleBarOverlay(mMapView);
mScaleBarOverlay.setScaleBarOffset(0,(int)(40 * dm.density));
mScaleBarOverlay.setCentred(true);
mScaleBarOverlay.setScaleBarOffset(dm.widthPixels / 2, 10);
mMapView.getOverlays().add(mScaleBarOverlay);
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:17,代码来源:SampleRotation.java
示例3: setUpMapIfNeeded
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
/**
* Description: Initialises the Map and sets initial options such as:
* Zoom levels and controls
* Compass
* ScaleBar
* Cluster Pin colors
* Location update settings
*/
private void setUpMapIfNeeded() {
// Check if we were successful in obtaining the map.
mMap.setBuiltInZoomControls(true);
mMap.setMultiTouchControls(true);
mMap.setMinZoomLevel(3);
mMap.setMaxZoomLevel(19); // Latest OSM can go to 21!
mMap.getTileProvider().createTileCache();
mCompassOverlay = new CompassOverlay(this, new InternalCompassOrientationProvider(this), mMap);
ScaleBarOverlay mScaleBarOverlay = new ScaleBarOverlay(this);
mScaleBarOverlay.setScaleBarOffset(getResources().getDisplayMetrics().widthPixels / 2, 10);
mScaleBarOverlay.setCentred(true);
// Sets cluster pin color
mCellTowerGridMarkerClusterer = new CellTowerGridMarkerClusterer(MapViewerOsmDroid.this);
//BitmapDrawable mapPinDrawable = (BitmapDrawable) getResources().getDrawable(R.drawable.ic_map_pin_orange);
BitmapDrawable mapPinDrawable = (BitmapDrawable) ResourcesCompat.getDrawable(getResources(),R.drawable.ic_map_pin_orange, null);
mCellTowerGridMarkerClusterer.setIcon(mapPinDrawable == null ? null : mapPinDrawable.getBitmap());
GpsMyLocationProvider gpsMyLocationProvider = new GpsMyLocationProvider(MapViewerOsmDroid.this.getBaseContext());
gpsMyLocationProvider.setLocationUpdateMinDistance(100); // [m] // Set the minimum distance for location updates
gpsMyLocationProvider.setLocationUpdateMinTime(10000); // [ms] // Set the minimum time interval for location updates
mMyLocationOverlay = new MyLocationNewOverlay(MapViewerOsmDroid.this.getBaseContext(), gpsMyLocationProvider, mMap);
mMyLocationOverlay.setDrawAccuracyEnabled(true);
mMap.getOverlays().add(mCellTowerGridMarkerClusterer);
mMap.getOverlays().add(mMyLocationOverlay);
mMap.getOverlays().add(mCompassOverlay);
mMap.getOverlays().add(mScaleBarOverlay);
}
开发者ID:5GSD,项目名称:AIMSICDL,代码行数:41,代码来源:MapViewerOsmDroid.java
示例4: setUpMapIfNeeded
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
/**
* Description: Initialises the Map and sets initial options such as:
* Zoom levels and controls
* Compass
* ScaleBar
* Cluster Pin colors
* Location update settings
*/
private void setUpMapIfNeeded() {
// Check if we were successful in obtaining the map.
mMap.setBuiltInZoomControls(true);
mMap.setMultiTouchControls(true);
mMap.setMinZoomLevel(3);
mMap.setMaxZoomLevel(19); // Latest OSM can go to 21!
mMap.getTileProvider().createTileCache();
mCompassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), mMap);
ScaleBarOverlay mScaleBarOverlay = new ScaleBarOverlay(getActivity());
mScaleBarOverlay.setScaleBarOffset(getResources().getDisplayMetrics().widthPixels / 2, 10);
mScaleBarOverlay.setCentred(true);
// Sets cluster pin color
mCellTowerGridMarkerClusterer = new CellTowerGridMarkerClusterer(getActivity());
BitmapDrawable mapPinDrawable = (BitmapDrawable) getResources().getDrawable(R.drawable.ic_map_pin_orange);
mCellTowerGridMarkerClusterer.setIcon(mapPinDrawable == null ? null : mapPinDrawable.getBitmap());
GpsMyLocationProvider gpsMyLocationProvider = new GpsMyLocationProvider(getActivity().getBaseContext());
gpsMyLocationProvider.setLocationUpdateMinDistance(100); // [m] // Set the minimum distance for location updates
gpsMyLocationProvider.setLocationUpdateMinTime(10000); // [ms] // Set the minimum time interval for location updates
mMyLocationOverlay = new MyLocationNewOverlay(getActivity().getBaseContext(), gpsMyLocationProvider, mMap);
mMyLocationOverlay.setDrawAccuracyEnabled(true);
mMap.getOverlays().add(mCellTowerGridMarkerClusterer);
mMap.getOverlays().add(mMyLocationOverlay);
mMap.getOverlays().add(mCompassOverlay);
mMap.getOverlays().add(mScaleBarOverlay);
}
开发者ID:anticomarley,项目名称:Android-IMSI-Catcher-Detector,代码行数:39,代码来源:MapFragment.java
示例5: setUpMapIfNeeded
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
/**
* Description: Initialises the Map and sets initial options such as:
* Zoom levels and controls
* Compass
* ScaleBar
* Cluster Pin colors
* Location update settings
*/
private void setUpMapIfNeeded() {
// Check if we were successful in obtaining the map.
mMap.setBuiltInZoomControls(true);
mMap.setMultiTouchControls(true);
mMap.setMinZoomLevel(3);
mMap.setMaxZoomLevel(19); // Latest OSM can go to 21!
mMap.getTileProvider().createTileCache();
mCompassOverlay = new CompassOverlay(this, new InternalCompassOrientationProvider(this), mMap);
ScaleBarOverlay mScaleBarOverlay = new ScaleBarOverlay(this);
mScaleBarOverlay.setScaleBarOffset(getResources().getDisplayMetrics().widthPixels / 2, 10);
mScaleBarOverlay.setCentred(true);
// Sets cluster pin color
mCellTowerGridMarkerClusterer = new CellTowerGridMarkerClusterer(MapViewerOsmDroid.this);
BitmapDrawable mapPinDrawable = (BitmapDrawable) getResources().getDrawable(R.drawable.ic_map_pin_orange);
mCellTowerGridMarkerClusterer.setIcon(mapPinDrawable == null ? null : mapPinDrawable.getBitmap());
GpsMyLocationProvider gpsMyLocationProvider = new GpsMyLocationProvider(MapViewerOsmDroid.this.getBaseContext());
gpsMyLocationProvider.setLocationUpdateMinDistance(100); // [m] // Set the minimum distance for location updates
gpsMyLocationProvider.setLocationUpdateMinTime(10000); // [ms] // Set the minimum time interval for location updates
mMyLocationOverlay = new MyLocationNewOverlay(MapViewerOsmDroid.this.getBaseContext(), gpsMyLocationProvider, mMap);
mMyLocationOverlay.setDrawAccuracyEnabled(true);
mMap.getOverlays().add(mCellTowerGridMarkerClusterer);
mMap.getOverlays().add(mMyLocationOverlay);
mMap.getOverlays().add(mCompassOverlay);
mMap.getOverlays().add(mScaleBarOverlay);
}
开发者ID:anticomarley,项目名称:Android-IMSI-Catcher-Detector,代码行数:39,代码来源:MapViewerOsmDroid.java
示例6: onCreateView
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
fragmentView = (LinearLayout) inflater.inflate(R.layout.main, container, false);
layout1 = (LinearLayout) fragmentView.findViewById(R.id.linearLayout1);
layout2 = (LinearLayout) fragmentView.findViewById(R.id.linearLayout2);
layout4 = (LinearLayout) fragmentView.findViewById(R.id.linearLayout4);
layout5 = (LinearLayout) fragmentView.findViewById(R.id.linearLayout5);
defineWidgets(fragmentView);
if (savedInstanceState != null)
chrono.setBase(chronoBaseValue);
chrono.setOnChronometerTickListener(new OnChronometerTickListener() {
public void onChronometerTick(Chronometer arg0) {
showCalculatedData(arg0);
if (prefs.getInt("practice_display5", TypesOfPractices.BASIC_PRACTICE.getTypes()) == TypesOfPractices.HIIT_PRACTICE
.getTypes())
showHiitTrainingDataInDisplay(arg0);
}
});
mapView = (MapView) fragmentView.findViewById(R.id.practice_mapview);
mapView.getOverlays().clear();
mapView.setBuiltInZoomControls(true);
mapView.setMultiTouchControls(true);
mapView.setUseSafeCanvas(true);
setHardwareAccelerationOff();
mapController = (MapController) mapView.getController();
ScaleBarOverlay mScaleBarOverlay = new ScaleBarOverlay(mContext);
mapView.getOverlays().add(mScaleBarOverlay);
pathOverlay = new PathOverlay(Color.BLUE, mContext);
pathOverlay.getPaint().setStyle(Style.STROKE);
pathOverlay.getPaint().setStrokeWidth(3);
pathOverlay.getPaint().setAntiAlias(true);
mapView.getOverlays().add(pathOverlay);
this.mCompassOverlay = new CompassOverlay(mContext, new InternalCompassOrientationProvider(mContext),
mapView);
mCompassOverlay.setEnabled(true);
mapView.getOverlays().add(mCompassOverlay);
this.mLocationOverlay = new MyLocationNewOverlay(mContext, new GpsMyLocationProvider(mContext),
mapView);
mLocationOverlay.setDrawAccuracyEnabled(true);
mapView.getOverlays().add(mLocationOverlay);
MapOverlay touchOverlay = new MapOverlay(mContext);
mapView.getOverlays().add(touchOverlay);
mLocationOverlay.runOnFirstFix(new Runnable() {
public void run() {
if (centerPoint == null)
centerPoint = mLocationOverlay.getMyLocation();
centerMyLocation(centerPoint);
}
});
mapView.postInvalidate();
return fragmentView;
}
开发者ID:scintero,项目名称:moveon,代码行数:70,代码来源:Main.java
示例7: onCreate
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myOpenMapView = (MapView) findViewById(R.id.openmapview);
myOpenMapView.setBuiltInZoomControls(true);
myMapController = myOpenMapView.getController();
myMapController.setZoom(18);
context = getApplicationContext();
overlayItemArray = new ArrayList<OverlayItem>();
new LongRunningGetIO().execute();
// Add Scale Bar
ScaleBarOverlay myScaleBarOverlay = new ScaleBarOverlay(this);
myOpenMapView.getOverlays().add(myScaleBarOverlay);
// Add MyLocationOverlay
// myLocationOverlay = new MyLocationNewOverlay(this, myOpenMapView);
// myLocationOverlay.enableMyLocation();
// myOpenMapView.getOverlays().add(myLocationOverlay);
// myOpenMapView.postInvalidate();
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Location lastLocation = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
firtLocation = true;
if (lastLocation != null) {
updateLoc(lastLocation);
}
}
开发者ID:TareeqH,项目名称:GeoWork,代码行数:31,代码来源:myApp.java
示例8: addOverlays
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
@Override
public void addOverlays() {
mMapView.setUseDataConnection(false);
final ScaleBarOverlay scaleBarOverlay = new ScaleBarOverlay(mMapView);
scaleBarOverlay.setCentred(true);
scaleBarOverlay.setScaleBarOffset(200, 10);
mMapView.getOverlays().add(scaleBarOverlay);
final ITileSource tileSource = new XYTileSource(
"Abstract", 0, 29, 256, ".png", new String[]{"http://localhost/"}, "abstract data");
mMapView.setUseDataConnection(false);
final MapTileAssetsProvider assetsProvider = new MapTileAssetsProvider(new SimpleRegisterReceiver(getContext()), getActivity().getAssets(), tileSource);
final MapTileApproximater approximationProvider = new MapTileApproximater();
approximationProvider.addProvider(assetsProvider);
final MapTileProviderArray array = new MapTileProviderArray(
tileSource, new SimpleRegisterReceiver(getContext()),
new MapTileModuleProviderBase[]{assetsProvider, approximationProvider});
mMapView.setTileProvider(array);
mMapView.getController().setZoom(29.);
// cf. https://fr.wikipedia.org/wiki/Point_z%C3%A9ro_des_routes_de_France
// In English: starting point of all French roads
mMapView.setExpectedCenter(new GeoPoint(48.85340215825712, 2.348784611094743));
mMapView.invalidate();
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:31,代码来源:SampleVeryHighZoomLevel.java
示例9: addOverlayScaleBar
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
public void addOverlayScaleBar(boolean toAdd) {
List<Overlay> overlays = mapView.getOverlays();
if (toAdd) {
// Add
boolean isNotInOverlays = true;
if (mScaleBarOverlay == null) {
mScaleBarOverlay = searchOverlays(ScaleBarOverlay.class);
}
if (mScaleBarOverlay != null) {
isNotInOverlays = false;
} else {
this.mScaleBarOverlay = new ScaleBarOverlay(getActivity(), mResourceProxy);
this.mScaleBarOverlay.setMetric();
// Scale bar tries to draw as 1-inch, so to put it in the top center, set x offset to
// half screen width, minus half an inch.
this.mScaleBarOverlay.setScaleBarOffset(getResources().getDisplayMetrics().widthPixels
/ 2 - getResources().getDisplayMetrics().xdpi / 2, 10);
}
if (isNotInOverlays) {
overlays.add(mScaleBarOverlay);
}
} else {
// Delete
if (mScaleBarOverlay != null) {
overlays.remove(mScaleBarOverlay);
mScaleBarOverlay = null;
}
}
}
开发者ID:gabuzomeu,项目名称:osmLib,代码行数:30,代码来源:OsmMapFragment.java
示例10: setUpMapIfNeeded
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
/**
* Description: Initialises the Map and sets initial options such as:
* Zoom levels and controls
* Compass
* ScaleBar
* Cluster Pin colors
* Location update settings
*/
private void setUpMapIfNeeded() {
// Check if we were successful in obtaining the map.
mMap.setBuiltInZoomControls(true);
mMap.setMultiTouchControls(true);
mMap.setMinZoomLevel(3);
mMap.setMaxZoomLevel(19); // Latest OSM can go to 21!
mMap.getTileProvider().createTileCache();
mCompassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), mMap);
ScaleBarOverlay mScaleBarOverlay = new ScaleBarOverlay(getActivity());
mScaleBarOverlay.setScaleBarOffset(getResources().getDisplayMetrics().widthPixels / 2, 10);
mScaleBarOverlay.setCentred(true);
// Sets cluster pin color
mCellTowerGridMarkerClusterer = new CellTowerGridMarkerClusterer(getActivity());
//BitmapDrawable mapPinDrawable = (BitmapDrawable) getResources().getDrawable(R.drawable.ic_map_pin_orange);
BitmapDrawable mapPinDrawable = (BitmapDrawable) ResourcesCompat.getDrawable(getResources(), R.drawable.ic_map_pin_orange, null);
mCellTowerGridMarkerClusterer.setIcon(mapPinDrawable == null ? null : mapPinDrawable.getBitmap());
GpsMyLocationProvider gpsMyLocationProvider = new GpsMyLocationProvider(getActivity().getBaseContext());
gpsMyLocationProvider.setLocationUpdateMinDistance(100); // [m] // Set the minimum distance for location updates
gpsMyLocationProvider.setLocationUpdateMinTime(10000); // [ms] // Set the minimum time interval for location updates
mMyLocationOverlay = new MyLocationNewOverlay(getActivity().getBaseContext(), gpsMyLocationProvider, mMap);
mMyLocationOverlay.setDrawAccuracyEnabled(true);
mMap.getOverlays().add(mCellTowerGridMarkerClusterer);
mMap.getOverlays().add(mMyLocationOverlay);
mMap.getOverlays().add(mCompassOverlay);
mMap.getOverlays().add(mScaleBarOverlay);
}
开发者ID:5GSD,项目名称:AIMSICDL,代码行数:40,代码来源:MapFragment.java
示例11: refreshLocationsOnMap
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
public void refreshLocationsOnMap(){
map.getOverlays().clear();
map.invalidate();
placeMarkers.clear();
allPlaces = Place.getAll();
for(Place place: allPlaces){
OverlayItem placeOverlayItem = new OverlayItem(
place.getAddress(), place.getDescription(), new GeoPoint(place.getLatitude(), place.getLongitude()));
Drawable myCurrentLocationMarker = this.getResources().getDrawable(R.drawable.marker_cloud);
placeOverlayItem.setMarker(myCurrentLocationMarker);
placeMarkers.add(placeOverlayItem);
}
// add my current location overlay
if(currentLocation != null){
OverlayItem myLocationOverlayItem = new OverlayItem("Here", "Current location",
new GeoPoint(currentLocation.getLatitude(), currentLocation.getLongitude()));
myLocationOverlayItem.setMarkerHotspot(OverlayItem.HotspotPlace.CENTER);
placeMarkers.add(myLocationOverlayItem);
}
ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay
= new ItemizedIconOverlay<OverlayItem>(
getActivity(), placeMarkers, null);
map.getOverlays().add(anotherItemizedIconOverlay);
ScaleBarOverlay myScaleBarOverlay = new ScaleBarOverlay(map);
map.getOverlays().add(myScaleBarOverlay);
MyLocationNewOverlay mLocationOverlay = new MyLocationNewOverlay(new GpsMyLocationProvider(getActivity()), map);
map.getOverlays().add(mLocationOverlay);
CompassOverlay mCompassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), map);
map.getOverlays().add(mCompassOverlay);
/*RotationGestureOverlay mRotationGestureOverlay = new RotationGestureOverlay(getActivity(), map);
mRotationGestureOverlay.setEnabled(true);
map.setMultiTouchControls(true);
map.getOverlays().add(mRotationGestureOverlay);*/
setBoundingBox();
}
开发者ID:hamzux,项目名称:cosi,代码行数:51,代码来源:PlacesFragment.java
示例12: onCreate
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myOpenMapView = (MapView) findViewById(R.id.openmapview);
myOpenMapView.setBuiltInZoomControls(true);
myMapController = myOpenMapView.getController();
myMapController.setZoom(20);
AndroidOpenStreetMapViewActivity.context = getApplicationContext();
// --- Create Overlay
overlayItemArray = new ArrayList<OverlayItem>();
DefaultResourceProxyImpl defaultResourceProxyImpl = new DefaultResourceProxyImpl(
this);
MyItemizedIconOverlay myItemizedIconOverlay = new MyItemizedIconOverlay(
overlayItemArray, null, defaultResourceProxyImpl);
myOpenMapView.getOverlays().add(myItemizedIconOverlay);
// ---
//
// --- Create Another Overlay for multi marker
anotherOverlayItemArray = new ArrayList<OverlayItem>();
new LongRunningGetIO().execute();
// buildPoints();
// ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay = new
// ItemizedIconOverlay<OverlayItem>(
// this, anotherOverlayItemArray, myOnItemGestureListener);
// myOpenMapView.getOverlays().add(anotherItemizedIconOverlay);
//
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// for demo, getLastKnownLocation from GPS only, not from NETWORK
Location lastLocation = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (lastLocation != null) {
updateLoc(lastLocation);
}
// Add Scale Bar
ScaleBarOverlay myScaleBarOverlay = new ScaleBarOverlay(this);
myOpenMapView.getOverlays().add(myScaleBarOverlay);
}
开发者ID:TareeqH,项目名称:GeoWork,代码行数:49,代码来源:AndroidOpenStreetMapViewActivity.java
示例13: onActivityCreated
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final Context context = this.getActivity();
final DisplayMetrics dm = context.getResources().getDisplayMetrics();
// mResourceProxy = new ResourceProxyImpl(getActivity().getApplicationContext());
mPrefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
this.mLocationOverlay = new MyLocationNewOverlay(new GpsMyLocationProvider(context),
mMapView);
mMinimapOverlay = new MinimapOverlay(context, mMapView.getTileRequestCompleteHandler());
mMinimapOverlay.setWidth(dm.widthPixels / 5);
mMinimapOverlay.setHeight(dm.heightPixels / 5);
mCopyrightOverlay = new CopyrightOverlay(context);
//i hate this very much, but it seems as if certain versions of android and/or
//device types handle screen offsets differently
if (Build.VERSION.SDK_INT <= 10)
mCopyrightOverlay.setOffset(0,(int)(55*dm.density));
mScaleBarOverlay = new ScaleBarOverlay(mMapView);
mScaleBarOverlay.setCentred(true);
mScaleBarOverlay.setScaleBarOffset(dm.widthPixels / 2, 10);
mRotationGestureOverlay = new RotationGestureOverlay(mMapView);
mRotationGestureOverlay.setEnabled(true);
mMapView.setBuiltInZoomControls(true);
mMapView.setMultiTouchControls(true);
mMapView.setTilesScaledToDpi(false);
mMapView.getOverlays().add(this.mLocationOverlay);
mMapView.getOverlays().add(this.mCopyrightOverlay);
mMapView.getOverlays().add(this.mMinimapOverlay);
mMapView.getOverlays().add(this.mScaleBarOverlay);
mMapView.getOverlays().add(this.mRotationGestureOverlay);
final float zoomLevel = mPrefs.getFloat(PREFS_ZOOM_LEVEL_DOUBLE, mPrefs.getInt(PREFS_ZOOM_LEVEL, 1));
mMapView.getController().setZoom(zoomLevel);
final float orientation = mPrefs.getFloat(PREFS_ORIENTATION, 0);
mMapView.setMapOrientation(orientation, false);
final String latitudeString = mPrefs.getString(PREFS_LATITUDE_STRING, null);
final String longitudeString = mPrefs.getString(PREFS_LONGITUDE_STRING, null);
if (latitudeString == null || longitudeString == null) { // case handled for historical reasons only
final int scrollX = mPrefs.getInt(PREFS_SCROLL_X, 0);
final int scrollY = mPrefs.getInt(PREFS_SCROLL_Y, 0);
mMapView.scrollTo(scrollX, scrollY);
} else {
final double latitude = Double.valueOf(latitudeString);
final double longitude = Double.valueOf(longitudeString);
mMapView.setExpectedCenter(new GeoPoint(latitude, longitude));
}
mLocationOverlay.enableMyLocation();
//sorry for the spaghetti code this is to filter out the compass on api 8
//Note: the compass overlay causes issues on API 8 devices. See https://github.com/osmdroid/osmdroid/issues/218
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
mCompassOverlay = new CompassOverlay(context, new InternalCompassOrientationProvider(context),
mMapView);
mCompassOverlay.enableCompass();
mMapView.getOverlays().add(this.mCompassOverlay);
}
setHasOptionsMenu(true);
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:73,代码来源:StarterMapFragment.java
示例14: onCreate
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
/** Called when the activity is first created. */
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final RelativeLayout rl = new RelativeLayout(this);
this.mMapView = new MapView(this);
this.mMapView.setTilesScaledToDpi(true);
this.mOsmvController = this.mMapView.getController();
rl.addView(this.mMapView, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
/* Scale Bar Overlay */
{
this.mScaleBarOverlay = new ScaleBarOverlay(mMapView);
this.mMapView.getOverlays().add(mScaleBarOverlay);
// Scale bar tries to draw as 1-inch, so to put it in the top center, set x offset to
// half screen width, minus half an inch.
this.mScaleBarOverlay.setScaleBarOffset(
(int) (getResources().getDisplayMetrics().widthPixels / 2 - getResources()
.getDisplayMetrics().xdpi / 2), 10);
}
/* SingleLocation-Overlay */
{
/*
* Create a static Overlay showing a single location. (Gets updated in
* onLocationChanged(Location loc)!
*/
this.mMyLocationOverlay = new SimpleLocationOverlay(((BitmapDrawable)getResources().getDrawable(org.osmdroid.library.R.drawable.person)).getBitmap());
this.mMapView.getOverlays().add(mMyLocationOverlay);
}
mMapView.setBuiltInZoomControls(true);
/* MiniMap */
{
mMiniMapOverlay = new MinimapOverlay(this, mMapView.getTileRequestCompleteHandler());
this.mMapView.getOverlays().add(mMiniMapOverlay);
}
// Default location and zoom level
IMapController mapController = mMapView.getController();
mapController.setZoom(13);
GeoPoint startPoint = new GeoPoint(50.936255, 6.957779);
mapController.setCenter(startPoint);
// PathOverlay pathOverlay = new PathOverlay(Color.RED, this);
// pathOverlay.addPoint(new GeoPoint(40.714623, -74.006605));
// pathOverlay.addPoint(new GeoPoint(38.8951118, -77.0363658));
// pathOverlay.addPoint(new GeoPoint(34.052186, -118.243932));
// pathOverlay.getPaint().setStrokeWidth(50.0f);
// pathOverlay.setAlpha(100);
// this.mMapView.getOverlays().add(pathOverlay);
this.setContentView(rl);
}
开发者ID:osmdroid,项目名称:osmdroid,代码行数:59,代码来源:SampleExtensive.java
示例15: onCreateView
import org.osmdroid.views.overlay.ScaleBarOverlay; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final Context context;
final DisplayMetrics dm;
View v = inflater.inflate(R.layout.fragment_map, container, false);
Views.inject(this, v);
context = inflater.getContext();
dm = context.getResources().getDisplayMetrics();
final int actionBarHeight;
TypedValue tv = new TypedValue();
if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
{
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,getResources().getDisplayMetrics());
}else {
actionBarHeight = 48;
}
mMapView = new MapView(inflater.getContext(), 256, mResourceProxy);
mMapView.setUseSafeCanvas(true);
mMapView.setBuiltInZoomControls(true);
mMapView.setMultiTouchControls(true);
mMapView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
mPathOverlay = new SolutionPathOverlay(mResourceProxy);
mMyLocationOverlay = new MyLocationNewOverlay(context, mMyLocationProvider,
mMapView, mResourceProxy);
mCompassOverlay = new CompassOverlay(context, new InternalCompassOrientationProvider(context),
mMapView, mResourceProxy);
mCompassOverlay.setCompassCenter(25.0f * dm.density, actionBarHeight + 5.0f * dm.density);
mScaleBarOverlay = new ScaleBarOverlay(context);
mScaleBarOverlay.setCentred(true);
mScaleBarOverlay.setScaleBarOffset(dm.widthPixels/2, actionBarHeight + 5.0f * dm.density);
mMapView.getOverlays().add(mPathOverlay);
mMapView.getOverlays().add(mScaleBarOverlay);
mMapView.getOverlays().add(mMyLocationOverlay);
mMapView.getOverlays().add(mCompassOverlay);
mMapViewContainer.addView(mMapView, 0);
return v;
}
开发者ID:illarionov,项目名称:RtkGps,代码行数:49,代码来源:MapFragment.java
注:本文中的org.osmdroid.views.overlay.ScaleBarOverlay类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论