本文整理匯總了Java中org.osmdroid.views.MapView.getController方法的典型用法代碼示例。如果您正苦於以下問題:Java MapView.getController方法的具體用法?Java MapView.getController怎麽用?Java MapView.getController使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.osmdroid.views.MapView
的用法示例。
在下文中一共展示了MapView.getController方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: mapSetup
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
private void mapSetup() {
map = (MapView) getActivity().findViewById(R.id.createPoiMap);
//important! set your user agent to prevent getting banned from the osm servers
Configuration.getInstance().load(getActivity(), PreferenceManager.getDefaultSharedPreferences(getActivity()));
map.setTileSource(TileSourceFactory.MAPNIK);
map.setTilesScaledToDpi(true);
// add multi-touch capability
map.setMultiTouchControls(true);
// add compass to map
CompassOverlay compassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), map);
compassOverlay.enableCompass();
map.getOverlays().add(compassOverlay);
// get map controller
IMapController controller = map.getController();
GeoPoint position = new GeoPoint(latitude, longitude);
controller.setCenter(position);
controller.setZoom(18);
MapUtils.addMarker(getActivity(), map, latitude, longitude);
}
示例2: mapSetup
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
private void mapSetup() {
map = (MapView) getActivity().findViewById(R.id.map); // create basic map
mController = map.getController(); // get map controller
map.setTileSource(TileSourceFactory.MAPNIK);
map.setTilesScaledToDpi(true);
map.setMultiTouchControls(true);
// add compass to map
CompassOverlay compassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), map);
compassOverlay.enableCompass();
map.getOverlays().add(compassOverlay);
//attach listeners
MapEventsOverlay mapEventsOverlay = new MapEventsOverlay(this);
map.getOverlays().add(0, mapEventsOverlay);
setupMyLocation();
}
示例3: setupMapPreview
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
private void setupMapPreview(double lat, double lon, String markerTitle) {
//important! set your user agent to prevent getting banned from the osm servers
Configuration.getInstance().load(getDialog().getContext(), PreferenceManager.getDefaultSharedPreferences(getDialog().getContext()));
map = (MapView) getDialog().findViewById(R.id.poiDialogMap);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setTilesScaledToDpi(true);
map.setMultiTouchControls(true);
// add compass to map
CompassOverlay compassOverlay = new CompassOverlay(getDialog().getContext(), new InternalCompassOrientationProvider(getDialog().getContext()), map);
compassOverlay.enableCompass();
map.getOverlays().add(compassOverlay);
// get map controller
IMapController controller = map.getController();
GeoPoint position = new GeoPoint(lat, lon);
controller.setCenter(position);
controller.setZoom(18);
MapUtils.addMarker(getActivity(), map, lat, lon, markerTitle);
}
示例4: mapSetup
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
private void mapSetup() {
map = (MapView) getActivity().findViewById(R.id.createPoiMap);
//important! set your user agent to prevent getting banned from the osm servers
Configuration.getInstance().load(getActivity(), PreferenceManager.getDefaultSharedPreferences(getActivity()));
map.setTileSource(TileSourceFactory.MAPNIK);
map.setTilesScaledToDpi(true);
map.setMultiTouchControls(true);
CompassOverlay compassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), map);
compassOverlay.enableCompass();
map.getOverlays().add(compassOverlay);
IMapController controller = map.getController();
GeoPoint position = new GeoPoint(POI.getLatitude(), POI.getLongitude());
controller.setCenter(position);
controller.setZoom(18);
MapUtils.addMarker(getActivity(), map, POI.getLatitude(), POI.getLongitude());
}
示例5: onCreate
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MapView mapView = (MapView) findViewById(R.id.map_view);
mapView.setTileSource(TileSourceFactory.PUBLIC_TRANSPORT);
mapView.setBuiltInZoomControls(true);
mapView.setMultiTouchControls(true);
IMapController mapController = mapView.getController();
mapController.setZoom(9);
GeoPoint location = new GeoPoint(27.7166667,85.3166667);
mapController.setCenter(location);
}
示例6: onCreate
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_request);
write();
move();
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
// initialize display map
map = (MapView) findViewById(R.id.addRequestMap);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
startPoint = new GeoPoint(53.52676, -113.52715);
IMapController mapController = map.getController();
mapController.setZoom(10);
mapController.setCenter(startPoint);
getLocations();
}
示例7: onCreate
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initialize map
setContentView(R.layout.activity_map);
MapView map = (MapView) findViewById(R.id.map_Map);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
GeoPoint startPoint = new GeoPoint(53.52676, -113.52715);
IMapController mapController = map.getController();
mapController.setZoom(10);
mapController.setCenter(startPoint);
move();
}
示例8: onCreate
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_requests);
write();
move();
// Initialize map
map = (MapView) findViewById(R.id.Map);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
startPoint = new GeoPoint(53.52676, -113.52715);
IMapController mapController = map.getController();
mapController.setZoom(10);
mapController.setCenter(startPoint);
getLocation();
}
示例9: onCreateView
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
mContext = inflater.getContext();
mResourceProxy = new ResourceProxyImpl(mContext.getApplicationContext());
mMapView = new MapView(inflater.getContext(), 256, mResourceProxy);
mMapView.setTileSource(TileSourceFactory.MAPQUESTOSM);
mMapView.setBuiltInZoomControls(true);
mMapView.setMultiTouchControls(true);
mMapView.setUseDataConnection(true);
IMapController mapCtrl = mMapView.getController();
mapCtrl.setCenter(new GeoPoint(43.5, -80.5));
mapCtrl.setZoom(10);
mMapView.invalidate();
return mMapView;
}
示例10: zoom
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
private void zoom(MapView mapView, boolean ddragMode) {
if (isDebugEnabled()) debug("zoom",this);
// mapView.setC .zoomToBoundingBox(rect);
final Projection projection = mapView.getProjection();
IMapController controller = mapView.getController();
if (ddragMode) {
IGeoPoint start = projection.fromPixels(this.mStart.x, this.mStart.y);
IGeoPoint end = projection.fromPixels(this.mEnd.x, this.mEnd.y);
ZoomUtil.zoomTo(mapView, ZoomUtil.NO_ZOOM, start, end);
if (isDebugEnabled()) debug("zoom(ddrag mode)", start, "..", end,
"=>", mapView.getMapCenter(), "z=", mapView.getZoomLevel());
} else {
IGeoPoint center = projection.fromPixels(this.mStart.x, this.mStart.y);
controller.setCenter(center);
controller.zoomIn();
if (isDebugEnabled()) debug("zoom(to center of)", center,
"=>", mapView.getMapCenter(), "z=", mapView.getZoomLevel());
}
}
示例11: onCreate
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
setContentView(R.layout.activity_show_location);
// Get map view and configure it.
map = (MapView) findViewById(R.id.map);
map.setTileSource(Config.TILE_SOURCE_PROVIDER);
map.setBuiltInZoomControls(false);
map.setMultiTouchControls(true);
this.mapController = map.getController();
mapController.setZoom(Config.INITIAL_ZOOM_LEVEL);
mapController.setCenter(this.loc);
requestLocationUpdates();
}
示例12: getCurrentLocation
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
/**
* Sets up the map to be pinpointed on the user's location.
*/
// see code attribution
private void getCurrentLocation() {
if(ContextCompat.checkSelfPermission(activity,
Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(activity,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
MY_PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION);
} else {
lastLocation = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
if (lastLocation == null) {
lastLocation = new Location("");
lastLocation.setLatitude(0);
lastLocation.setLongitude(0);
}
latitude = lastLocation.getLatitude();
longitude = lastLocation.getLongitude();
MapView map = (MapView) findViewById(R.id.map);
GeoPoint startPoint = new GeoPoint(latitude,longitude);
IMapController mapController = map.getController();
mapController.setZoom(18);
if(locationPoint == null) {
mapController.setCenter(startPoint);
}
MapEventsOverlay mapEventsOverlay = new MapEventsOverlay(activity, (MapEventsReceiver) activity);
map.getOverlays().add(0, mapEventsOverlay);
}
}
示例13: onCreate
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rider_view_request);
// unpacking the bundle to get the position of request
Bundle bundle = getIntent().getExtras();
int position = bundle.getInt("position");
request = RequestController.getRiderInstance().get(position);
setTitle("Request");
map = (MapView) findViewById(R.id.map);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
startPoint = new GeoPoint(request.getStart());
endPoint = new GeoPoint(request.getEnd());
mapController = map.getController();
mapController.setCenter(getCenter());
zoomToBounds(getBoundingBox(startPoint, endPoint));
ArrayList<OverlayItem> overlayItems = new ArrayList<>();
overlayItems.add(new OverlayItem("Starting Point", "This is the starting point", startPoint));
overlayItems.add(new OverlayItem("Destination", "This is the destination point", endPoint));
setViews();
setMarkers();
getRoadAsync();
}
示例14: zoomTo
import org.osmdroid.views.MapView; //導入方法依賴的package包/類
/**
* Similar to MapView.zoomToBoundingBox that seems to be to inexact.
* @param mapView
* @param zoom if NO_ZOOM (-1) zoom is calculated from min and max
* @param min
* @param max
*/
public static void zoomTo(MapView mapView, int zoom, IGeoPoint min, IGeoPoint max) {
MapTileProviderBase tileProvider = mapView.getTileProvider();
IMapController controller = mapView.getController();
IGeoPoint center = min;
if (max != null) {
center = new GeoPoint((max.getLatitudeE6() + min.getLatitudeE6()) / 2, (max.getLongitudeE6() + min.getLongitudeE6()) / 2);
if (zoom == NO_ZOOM) {
final double requiredMinimalGroundResolutionInMetersPerPixel = ((double) new GeoPoint(min.getLatitudeE6(), min.getLongitudeE6()).distanceTo(max)) / Math.min(mapView.getWidth(), mapView.getHeight());
zoom = calculateZoom(center.getLatitude(), requiredMinimalGroundResolutionInMetersPerPixel, tileProvider.getMaximumZoomLevel(), tileProvider.getMinimumZoomLevel());
}
}
if (zoom != NO_ZOOM) {
controller.setZoom(zoom);
}
if (center != null) {
controller.setCenter(center);
}
/*
if (logger.isDebugEnabled()) {
logger.debug("DelayedSetCenterZoom.execute({}: ({}) .. ({}),z={}) => ({}), z={} => {}",
debugContext,
min, max, mZoomLevel, center, zoom, getStatusForDebug());
}
*/
}
示例15: onCreateView
import org.osmdroid.views.MapView; //導入方法依賴的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;
}