org.osmdroid.views.overlay.CopyrightOverlay Java Examples
The following examples show how to use
org.osmdroid.views.overlay.CopyrightOverlay.
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: SampleCopyrightOverlay.java From osmdroid with Apache License 2.0 | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Log.d(TAG, "onActivityCreated"); mMapView.getOverlays().clear(); CopyrightOverlay copyrightOverlay = new CopyrightOverlay(getActivity()); copyrightOverlay.setTextColor(Color.GREEN); copyrightOverlay.setTextSize(20); copyrightOverlay.setAlignBottom(true); copyrightOverlay.setAlignRight(false); copyrightOverlay.setOffset(20,40); //with align bottom and left, this should be 20dp from the bottom, 20dp from the left mMapView.getOverlays().add(copyrightOverlay); }
Example #2
Source File: BaseSampleFragment.java From osmdroid with Apache License 2.0 | 6 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Log.d(TAG, "onActivityCreated"); if (mMapView != null) { addOverlays(); final Context context = this.getActivity(); final DisplayMetrics dm = context.getResources().getDisplayMetrics(); CopyrightOverlay copyrightOverlay = new CopyrightOverlay(getActivity()); copyrightOverlay.setTextSize(10); mMapView.getOverlays().add(copyrightOverlay); mMapView.setMultiTouchControls(true); mMapView.setTilesScaledToDpi(true); } }
Example #3
Source File: LocationActivity.java From Conversations with GNU General Public License v3.0 | 5 votes |
protected void setupMapView(MapView mapView, final GeoPoint pos) { map = mapView; map.getOverlays().add(new CopyrightOverlay(this)); map.setTileSource(TileSourceFactory.MAPNIK); map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER); map.setMultiTouchControls(true); map.setTilesScaledToDpi(false); mapController = map.getController(); mapController.setZoom(Config.Map.INITIAL_ZOOM_LEVEL); mapController.setCenter(pos); }
Example #4
Source File: MapsActivity.java From Finder with GNU General Public License v3.0 | 4 votes |
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Context ctx = getApplicationContext(); Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx)); Configuration.getInstance().setUserAgentValue(BuildConfig.APPLICATION_ID); setContentView(R.layout.activity_open_map); SharedPreferences sPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); map = findViewById(R.id.map2); Configuration.getInstance().setTileFileSystemCacheMaxBytes(1024*1024*Long.parseLong(sPref.getString("cache_size", "5"))); Configuration.getInstance().setTileFileSystemCacheTrimBytes(512*1024*Long.parseLong(sPref.getString("cache_size", "5"))); // trim storage to ~50% from max after oversize limit if (sPref.getBoolean("satellite", false)) { final MapBoxTileSource tileSource = new MapBoxTileSource(); tileSource.retrieveAccessToken(this); tileSource.retrieveMapBoxMapId(this); map.setTileSource(tileSource); } else { map.setTileSource(TileSourceFactory.MAPNIK); } map.setBuiltInZoomControls(true); map.setMultiTouchControls(true); mapController = map.getController(); CopyrightOverlay copyOverlay = new CopyrightOverlay(this); copyOverlay.setAlignRight(true); map.getOverlays().add(copyOverlay); ScaleBarOverlay scaleBar= new ScaleBarOverlay(map); scaleBar.setUnitsOfMeasure(ScaleBarOverlay.UnitsOfMeasure.metric); scaleBar.setScaleBarOffset(getResources().getDisplayMetrics().widthPixels/2, 50); scaleBar.setCentred(true); map.getOverlays().add(scaleBar); GpsMyLocationProvider gpsProvider = new GpsMyLocationProvider(this.getBaseContext()); MyLocationNewOverlay myLoc = new MyLocationNewOverlay(gpsProvider, map); myLoc.setDrawAccuracyEnabled(true); map.getOverlays().add(myLoc); CompassOverlay compasOver = new CompassOverlay(this.getBaseContext(), map); compasOver.enableCompass(); map.getOverlays().add(compasOver); dBase baseConnect = new dBase(this); db = baseConnect.getWritableDatabase(); Intent intent = this.getIntent(); mapController.setZoom(intent.getDoubleExtra("zoom", 15.0d)); String act = intent.getAction(); if (act.equals("track")) { track_id = intent.getIntExtra("track_id", 0); line = new Polyline(map); line.setColor(Color.BLUE); line.setInfoWindow(null); //delete popup label from track line.setGeodesic(true); //draw "true" lines instead simple lines (great circles) trackRedraw(); map.getOverlays().add(line); } else { String accuracy = intent.getStringExtra("accuracy"); GeoPoint startPoint = new GeoPoint(intent.getDoubleExtra("lat", 0d), intent.getDoubleExtra("lon", 0d)); mapController.setCenter(startPoint); Marker startMarker = new Marker(map); startMarker.setPosition(startPoint); startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM); map.getOverlays().add(startMarker); startMarker.setTitle(accuracy); } //receiver to map updating LocalBroadcastManager.getInstance(this).registerReceiver(updMap, new IntentFilter("update_map")); }
Example #5
Source File: MapActivity.java From ActivityDiary with GNU General Public License v3.0 | 4 votes |
@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: StarterMapFragment.java From osmdroid with Apache License 2.0 | 4 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final Context context = this.getActivity(); final DisplayMetrics dm = context.getResources().getDisplayMetrics(); mPrefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); //My Location //note you have handle the permissions yourself, the overlay did not do it for you mLocationOverlay = new MyLocationNewOverlay(new GpsMyLocationProvider(context), mMapView); mLocationOverlay.enableMyLocation(); mMapView.getOverlays().add(this.mLocationOverlay); //Mini map mMinimapOverlay = new MinimapOverlay(context, mMapView.getTileRequestCompleteHandler()); mMinimapOverlay.setWidth(dm.widthPixels / 5); mMinimapOverlay.setHeight(dm.heightPixels / 5); mMapView.getOverlays().add(this.mMinimapOverlay); //Copyright overlay 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 mMapView.getOverlays().add(this.mCopyrightOverlay); //On screen compass mCompassOverlay = new CompassOverlay(context, new InternalCompassOrientationProvider(context), mMapView); mCompassOverlay.enableCompass(); mMapView.getOverlays().add(this.mCompassOverlay); //map scale mScaleBarOverlay = new ScaleBarOverlay(mMapView); mScaleBarOverlay.setCentred(true); mScaleBarOverlay.setScaleBarOffset(dm.widthPixels / 2, 10); mMapView.getOverlays().add(this.mScaleBarOverlay); //support for map rotation mRotationGestureOverlay = new RotationGestureOverlay(mMapView); mRotationGestureOverlay.setEnabled(true); mMapView.getOverlays().add(this.mRotationGestureOverlay); //needed for pinch zooms mMapView.setMultiTouchControls(true); //scales tiles to the current screen's DPI, helps with readability of labels mMapView.setTilesScaledToDpi(true); //the rest of this is restoring the last map location the user looked at final float zoomLevel = mPrefs.getFloat(PREFS_ZOOM_LEVEL_DOUBLE, 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, "1.0"); final String longitudeString = mPrefs.getString(PREFS_LONGITUDE_STRING, "1.0"); final double latitude = Double.valueOf(latitudeString); final double longitude = Double.valueOf(longitudeString); mMapView.setExpectedCenter(new GeoPoint(latitude, longitude)); setHasOptionsMenu(true); }
Example #7
Source File: SampleWithTilesOverlay.java From osmdroid with Apache License 2.0 | 4 votes |
/** Called when the activity is first created. */ @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Setup base map setContentView(R.layout.activity_samplewithtilesoverlay); Toolbar toolbar = findViewById(R.id.my_toolbar); setSupportActionBar(toolbar); //noinspection ConstantConditions getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); final LinearLayout mapContainer = findViewById(R.id.map_container); mMapView = new MapView(this); mMapView.setTilesScaledToDpi(true); mapContainer.addView(this.mMapView, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mMapView.getZoomController().setVisibility( CustomZoomButtonsController.Visibility.SHOW_AND_FADEOUT); //Copyright overlay String copyrightNotice = mMapView.getTileProvider().getTileSource().getCopyrightNotice(); CopyrightOverlay copyrightOverlay = new CopyrightOverlay(this); copyrightOverlay.setCopyrightNotice(copyrightNotice); mMapView.getOverlays().add(copyrightOverlay); // zoom to the netherlands mMapView.getController().setZoom(8.); mMapView.getController().setCenter(new GeoPoint(53.6, 5.3)); // Add tiles layer MapTileProviderBasic provider = new MapTileProviderBasic(getApplicationContext()); provider.setTileSource(TileSourceFactory.PUBLIC_TRANSPORT); TilesOverlay tilesOverlay = new TilesOverlay(provider, this.getBaseContext()); tilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT); mMapView.getOverlays().add(tilesOverlay); }
Example #8
Source File: SampleWithTilesOverlayAndCustomTileSource.java From osmdroid with Apache License 2.0 | 4 votes |
/** Called when the activity is first created. */ @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Setup base map setContentView(R.layout.activity_samplewithtilesoverlayandcustomtilesource); Toolbar toolbar = findViewById(R.id.my_toolbar); setSupportActionBar(toolbar); //noinspection ConstantConditions getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); final LinearLayout mapContainer = findViewById(R.id.map_container); mMapView = new MapView(this); mMapView.setTilesScaledToDpi(true); //Copyright overlay String copyrightNotice = mMapView.getTileProvider().getTileSource().getCopyrightNotice(); CopyrightOverlay copyrightOverlay = new CopyrightOverlay(this); copyrightOverlay.setCopyrightNotice(copyrightNotice); mMapView.getOverlays().add(copyrightOverlay); mapContainer.addView(mMapView, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mMapView.getZoomController().setVisibility( CustomZoomButtonsController.Visibility.SHOW_AND_FADEOUT); // zoom to the netherlands mMapView.getController().setZoom(7D); mMapView.getController().setCenter(new GeoPoint(51.5D, 5.4D)); // Add tiles layer with custom tile source final MapTileProviderBasic tileProvider = new MapTileProviderBasic(getApplicationContext()); final ITileSource tileSource = new XYTileSource("FietsRegionaal", 3, 18, 256, ".png", new String[] { "http://overlay.openstreetmap.nl/openfietskaart-rcn/" }); tileProvider.setTileSource(tileSource); tileProvider.getTileRequestCompleteHandlers().add(mMapView.getTileRequestCompleteHandler()); final TilesOverlay tilesOverlay = new TilesOverlay(tileProvider, this.getBaseContext()); tilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT); mMapView.getOverlays().add(tilesOverlay); }