Search in sources :

Example 1 with AbstractTileSource

use of org.mapsforge.map.layer.download.tilesource.AbstractTileSource in project RSAndroidApp by RailwayStations.

the class MapsActivity method createLayers.

protected void createLayers() {
    final String map = baseApplication.getMap();
    final Uri mapUri = baseApplication.toUri(map);
    final MapDataStore mapFile = getMapFile(mapUri);
    if (mapFile != null) {
        final TileRendererLayer rendererLayer = new TileRendererLayer(this.tileCaches.get(0), mapFile, this.binding.map.mapView.getModel().mapViewPosition, false, true, false, AndroidGraphicFactory.INSTANCE) {

            @Override
            public boolean onLongPress(final LatLong tapLatLong, final Point thisXY, final Point tapXY) {
                MapsActivity.this.onLongPress(tapLatLong);
                return true;
            }
        };
        rendererLayer.setXmlRenderTheme(getRenderTheme());
        this.layer = rendererLayer;
        binding.map.mapView.getLayerManager().getLayers().add(this.layer);
    } else {
        AbstractTileSource tileSource = onlineTileSources.get(map);
        if (tileSource == null) {
            tileSource = OpenStreetMapMapnik.INSTANCE;
        }
        tileSource.setUserAgent(USER_AGENT);
        this.layer = new TileDownloadLayer(this.tileCaches.get(0), this.binding.map.mapView.getModel().mapViewPosition, tileSource, AndroidGraphicFactory.INSTANCE) {

            @Override
            public boolean onLongPress(final LatLong tapLatLong, final Point thisXY, final Point tapXY) {
                MapsActivity.this.onLongPress(tapLatLong);
                return true;
            }
        };
        binding.map.mapView.getLayerManager().getLayers().add(this.layer);
        binding.map.mapView.setZoomLevelMin(tileSource.getZoomLevelMin());
        binding.map.mapView.setZoomLevelMax(tileSource.getZoomLevelMax());
    }
}
Also used : MapDataStore(org.mapsforge.map.datastore.MapDataStore) TileRendererLayer(org.mapsforge.map.layer.renderer.TileRendererLayer) TileDownloadLayer(org.mapsforge.map.layer.download.TileDownloadLayer) Point(org.mapsforge.core.model.Point) Uri(android.net.Uri) LatLong(org.mapsforge.core.model.LatLong) AbstractTileSource(org.mapsforge.map.layer.download.tilesource.AbstractTileSource)

Aggregations

Uri (android.net.Uri)1 LatLong (org.mapsforge.core.model.LatLong)1 Point (org.mapsforge.core.model.Point)1 MapDataStore (org.mapsforge.map.datastore.MapDataStore)1 TileDownloadLayer (org.mapsforge.map.layer.download.TileDownloadLayer)1 AbstractTileSource (org.mapsforge.map.layer.download.tilesource.AbstractTileSource)1 TileRendererLayer (org.mapsforge.map.layer.renderer.TileRendererLayer)1