Java Code Examples for org.osmdroid.tileprovider.MapTileProviderBasic

The following are top voted examples for showing how to use org.osmdroid.tileprovider.MapTileProviderBasic. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: osmdroid   File: SampleWithTilesOverlay.java   View source code 6 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	// Setup base map
	rl = new RelativeLayout(this);

	this.mMapView = new MapView(this);
	this.mMapView.setTilesScaledToDpi(true);
	rl.addView(this.mMapView, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
			LayoutParams.FILL_PARENT));
	this.mMapView.setBuiltInZoomControls(true);

	// zoom to the netherlands
	this.mMapView.getController().setZoom(7);
	this.mMapView.getController().setCenter(new GeoPoint(51500000, 5400000));

	// Add tiles layer
	mProvider = new MapTileProviderBasic(getApplicationContext());
	mProvider.setTileSource(TileSourceFactory.FIETS_OVERLAY_NL);
	this.mTilesOverlay = new TilesOverlay(mProvider, this.getBaseContext());
	this.mMapView.getOverlays().add(this.mTilesOverlay);

	this.setContentView(rl);
}
 
Example 2
Project: Android-Tariki.dz   File: MapsActivity.java   View source code 5 votes vote down vote up
@Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);

    ButterKnife.bind(this);

    if (Build.VERSION.SDK_INT >= 23) {
       new Permission(this);
    }

    final MapTileProviderBasic tileProvider = new MapTileProviderBasic(getApplicationContext());
    final ITileSource tileSource = new XYTileSource("Mapnik", 3, 19, 256, ".png",
            new String[] {Constants.TILE_SOURCE});
    //mapView.setTileSource((new XYTileSource("localMapnik", Resource, 0, 18, 256, ".png",
    //  "http://tile.openstreetmap.org/")));
    tileProvider.setTileSource(tileSource);
    map.setTileProvider(tileProvider);

    map.setBuiltInZoomControls(true);
    map.setMultiTouchControls(true);

    mapController = map.getController();
    mapController.setZoom(15);

    poiMarkers = new RadiusMarkerClusterer(this);
    map.getOverlays().add(poiMarkers);

    Drawable poiIcon = ResourcesCompat.getDrawable(getResources(), R.drawable.marker_male, null);
    myMarker = new Marker(map);
    poiMarkers.add(myMarker);

    snackbar = Snackbar
            .make(findViewById(android.R.id.content), getString(R.string.chargement_en_cours), Snackbar.LENGTH_INDEFINITE);

    presenter.onCreate();



    setupLocationManager();
}
 
Example 3
Project: fAlarm   File: OsmMapFragment.java   View source code 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_osm, container, false);
    mUnbinder = ButterKnife.bind(this, view);

    GeoPoint startPoint = new GeoPoint(mLat, mLng);

    mapView.setTileSource(TileSourceFactory.MAPNIK);
    mapView.setBuiltInZoomControls(true);
    mapView.setMultiTouchControls(true);
    mapView.setMaxZoomLevel(17);

    //create the second one
    final MapTileProviderBasic ofmTileProvider = new MapTileProviderBasic(getContext());
    final ITileSource ofmTileSource = new XYTileSource("OpenFireMap", 10, 17, 256, ".png",
            new String[]{"http://openfiremap.org/hytiles/"});
    ofmTileProvider.setTileSource(ofmTileSource);
    final TilesOverlay ofmTilesOverlay = new TilesOverlay(ofmTileProvider, getContext());
    ofmTilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
    mapView.getOverlays().add(ofmTilesOverlay);

    //Alarm Marker
    Marker startMarker = new Marker(mapView);
    startMarker.setPosition(startPoint);
    startMarker.setTitle(getString(R.string.operation_base));
    startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
    mapView.getOverlays().add(startMarker);

    IMapController mapController = mapView.getController();
    mapController.setZoom(startZoomLevel);
    mapController.setCenter(startPoint);

    return view;
}
 
Example 4
Project: osmdroid   File: SampleOpenSeaMap.java   View source code 5 votes vote down vote up
@Override
public void addOverlays(){
    super.addOverlays();
    mProvider = new MapTileProviderBasic(getContext());
    TilesOverlay seaMap = new TilesOverlay(mProvider, getContext());
    seaMap.setLoadingLineColor(Color.TRANSPARENT);
    seaMap.setLoadingBackgroundColor(Color.TRANSPARENT);
    seaMap.setLoadingDrawable(null);
    mProvider.setTileSource(TileSourceFactory.OPEN_SEAMAP);
    mMapView.getOverlays().add(seaMap);
    mMapView.postInvalidate();
    mMapView.getController().setCenter(new GeoPoint(40.65716,-74.06507));
    mMapView.getController().setZoom(18);
}
 
Example 5
Project: osmdroid   File: SampleWithTilesOverlayAndCustomTileSource.java   View source code 5 votes vote down vote up
/** Called when the activity is first created. */
@Override
public void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	// Setup base map
	final RelativeLayout rl = new RelativeLayout(this);

	mMapView = new MapView(this);
	mMapView.setTilesScaledToDpi(true);
	rl.addView(mMapView, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
			LayoutParams.FILL_PARENT));
	mMapView.setBuiltInZoomControls(true);

	// zoom to the netherlands
	mMapView.getController().setZoom(7);
	mMapView.getController().setCenter(new GeoPoint(51500000, 5400000));

	// 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);
	final TilesOverlay tilesOverlay = new TilesOverlay(tileProvider, this.getBaseContext());
	tilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);
	mMapView.getOverlays().add(tilesOverlay);

	this.setContentView(rl);
}
 
Example 6
Project: osmbonuspack   File: MapActivity.java   View source code 4 votes vote down vote up
void setStdTileProvider(){
	if (!(map.getTileProvider() instanceof MapTileProviderBasic)){
		MapTileProviderBasic bitmapProvider = new MapTileProviderBasic(this);
		map.setTileProvider(bitmapProvider);
	}
}
 
Example 7
Project: osmdroid   File: OpenStreetMapTileProviderDirectTest.java   View source code 3 votes vote down vote up
@Override
protected void setUp() throws Exception {

	mProvider = new MapTileProviderBasic(getContext());

	super.setUp();
}
 
Example 8
Project: osmdroid   File: MinimapOverlay.java   View source code 2 votes vote down vote up
/**
 * Creates a {@link MinimapOverlay} that uses its own {@link MapTileProviderBasic}. The
 * {@link Handler} passed in is typically the same handler being used by the main map.
 * 
 * @param pContext
 *            a context
 * @param pTileRequestCompleteHandler
 *            a handler for tile request complete notifications
 */
public MinimapOverlay(final Context pContext, final Handler pTileRequestCompleteHandler) {
	this(pContext, pTileRequestCompleteHandler, new MapTileProviderBasic(pContext));
}