Android Open Source - hellomap3d-android Mbtiles Activity






From Project

Back to project page hellomap3d-android.

License

The source code is released under:

MIT License

If you think the Android project hellomap3d-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.nutiteq.advancedmap3;
/*ww w .  j av a2s  .c  o m*/
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;

import android.os.Bundle;
import android.util.Log;

import com.nutiteq.core.MapRange;
import com.nutiteq.datasources.HTTPTileDataSource;
import com.nutiteq.datasources.MBTilesTileDataSource;
import com.nutiteq.datasources.PersistentCacheTileDataSource;
import com.nutiteq.datasources.TileDataSource;
import com.nutiteq.filepicker.FilePickerActivity;
import com.nutiteq.hellomap3.util.AssetCopy;
import com.nutiteq.layers.VectorTileLayer;
import com.nutiteq.utils.AssetUtils;
import com.nutiteq.vectortiles.MBVectorTileDecoder;
import com.nutiteq.vectortiles.MBVectorTileStyleSet;
import com.nutiteq.wrappedcommons.UnsignedCharVector;

public class MbtilesActivity extends VectorMapSampleBaseActivity implements
        FilePickerActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // read filename from extras
        Bundle b = getIntent().getExtras();
        String filePath = b.getString("selectedFile");

        // TODO: detect if raster or vector mtiles
        // TODO: read metadata: zoom range, default zoom and center
        //    query from data if metadata not available
        
        // replace baseLayer with new datasource
        
        MBTilesTileDataSource vectorTileDataSource = new MBTilesTileDataSource(
                0, 14, filePath);
        mapView.getLayers().remove(baseLayer);
        
        baseLayer = new VectorTileLayer(vectorTileDataSource,
                vectorTileDecoder);
        mapView.getLayers().add(baseLayer);

        mapView.getOptions().setZoomRange(new MapRange(0, 18));
        mapView.setZoom(3, 0);

    }

    @Override
    public String getFileSelectMessage() {
        return "Select MBTiles file (vector tiles or raster)";
    }

    @Override
    public FileFilter getFileFilter() {
        return new FileFilter() {
            @Override
            public boolean accept(File file) {
                // accept only readable files
                if (file.canRead()) {
                    if (file.isDirectory()) {
                        // allow to select any directory
                        return true;
                    } else if (file.isFile()
                            && file.getName().endsWith(".mbtiles")) {
                        // accept files with given extension
                        return true;
                    }
                }
                return false;
            };
        };
    }

}




Java Source Code List

com.nutiteq.advancedmap3.AerialMapActivity.java
com.nutiteq.advancedmap3.AnimatedRasterMapActivity.java
com.nutiteq.advancedmap3.Const.java
com.nutiteq.advancedmap3.CustomRasterDataSourceActivity.java
com.nutiteq.advancedmap3.GraphhopperRouteActivity.java
com.nutiteq.advancedmap3.LauncherList.java
com.nutiteq.advancedmap3.MapListenerActivity.java
com.nutiteq.advancedmap3.MapSampleBaseActivity.java
com.nutiteq.advancedmap3.MbtilesActivity.java
com.nutiteq.advancedmap3.OfflineVectorMapActivity.java
com.nutiteq.advancedmap3.Overlays2DActivity.java
com.nutiteq.advancedmap3.Overlays3DActivity.java
com.nutiteq.advancedmap3.PinMapActivity.java
com.nutiteq.advancedmap3.RasterOverlayActivity.java
com.nutiteq.advancedmap3.VectorMapSampleBaseActivity.java
com.nutiteq.advancedmap3.datasource.MyAnimatedTileDataSource.java
com.nutiteq.advancedmap3.datasource.MyMergedRasterTileDataSource.java
com.nutiteq.advancedmap3.listener.MyMapEventListener.java
com.nutiteq.advancedmap3.listener.RouteMapEventListener.java
com.nutiteq.filepicker.FilePickerActivity.java
com.nutiteq.filepicker.FilePickerIconAdapter.java
com.nutiteq.filepicker.FilePicker.java
com.nutiteq.hellomap3.MainActivity.java
com.nutiteq.hellomap3.util.AssetCopy.java