Java Code Examples for org.osmdroid.views.MapView#getController()

The following examples show how to use org.osmdroid.views.MapView#getController() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreatePoiFragment.java    From AndroidApp with Mozilla Public License 2.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: MapFragment.java    From AndroidApp with Mozilla Public License 2.0 6 votes vote down vote up
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();
}
 
Example 3
Source File: PoiDetailsFragment.java    From AndroidApp with Mozilla Public License 2.0 6 votes vote down vote up
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);
}
 
Example 4
Source File: MyLocationNewOverlay.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
public MyLocationNewOverlay(IMyLocationProvider myLocationProvider, MapView mapView) {
	super();
	mScale = mapView.getContext().getResources().getDisplayMetrics().density;

	mMapView = mapView;
	mMapController = mapView.getController();
	mCirclePaint.setARGB(0, 100, 100, 255);
	mCirclePaint.setAntiAlias(true);
	mPaint.setFilterBitmap(true);


	setDirectionArrow(((BitmapDrawable)mapView.getContext().getResources().getDrawable(R.drawable.person)).getBitmap(),
			((BitmapDrawable)mapView.getContext().getResources().getDrawable(R.drawable.twotone_navigation_black_48)).getBitmap());

	// Calculate position of person icon's feet, scaled to screen density
	mPersonHotspot = new PointF(24.0f * mScale + 0.5f, 39.0f * mScale + 0.5f);

	mHandler = new Handler(Looper.getMainLooper());
	setMyLocationProvider(myLocationProvider);
}
 
Example 5
Source File: MapActivity.java    From ActivityDiary with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Context ctx = getApplicationContext();
    Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx));

    LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View contentView = inflater.inflate(R.layout.activity_map, null, false);

    setContent(contentView);

    noMap = (TextView) findViewById(R.id.noMap);

    map = (MapView) findViewById(R.id.map);
    map.setTileSource(TileSourceFactory.MAPNIK);
    map.setTilesScaledToDpi(true);
    map.setBuiltInZoomControls(true);
    map.setMultiTouchControls(true);

    IMapController mapController = map.getController();
    mapController.setZoom(14.0);
    GeoPoint startPoint = new GeoPoint(LocationHelper.helper.getCurrentLocation());
    mapController.setCenter(startPoint);

    CopyrightOverlay copyrightOverlay = new CopyrightOverlay(this);
    copyrightOverlay.setTextSize(10);
    map.getOverlays().add(copyrightOverlay);

    ScaleBarOverlay scaleBarOverlay = new ScaleBarOverlay(map);
    map.getOverlays().add(scaleBarOverlay);
    // 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.
    scaleBarOverlay.setScaleBarOffset(
            (int) (getResources().getDisplayMetrics().widthPixels / 2 - getResources()
                    .getDisplayMetrics().xdpi / 2), 10);

    getLoaderManager().initLoader(LOADER_ID_INIT, null, this);

    mDrawerToggle.setDrawerIndicatorEnabled(false);
}
 
Example 6
Source File: OsmMapHandler.java    From FancyPlaces with GNU General Public License v3.0 4 votes vote down vote up
public OsmMapHandler(MapView mapView, OnFancyPlaceSelectedListener listener) {
    curMapView = mapView;
    curMapController = mapView.getController();
    fancyPlaceSelectedCallback = listener;
}