android - Mapsforge InternalRenderTheme 缺失错误

标签 android mapsforge

我尝试用mapsforge开始我的第一个项目。所以我这样做了,更改app/build.gradle

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'org.mapsforge:mapsforge-map-android:0.8.0'
    compile 'com.caverock:androidsvg:1.2.2-beta-1'
    compile('org.mapsforge:mapsforge-map-android-extras:0.8.0') {
        transitive = false
    }
}

然后,我从这里获取代码:Code Example App 。 这是我的主要 Activity

package kn.com.ff_map;

import android.os.Bundle;

import android.app.Activity;
import android.os.Environment;

import org.mapsforge.core.model.LatLong;
import org.mapsforge.map.android.graphics.AndroidGraphicFactory;
import org.mapsforge.map.android.util.AndroidUtil;
import org.mapsforge.map.android.view.MapView;
import org.mapsforge.map.datastore.MapDataStore;
import org.mapsforge.map.layer.cache.TileCache;
import org.mapsforge.map.layer.renderer.TileRendererLayer;
import org.mapsforge.map.reader.MapFile;
import org.mapsforge.map.rendertheme.InternalRenderTheme;

import java.io.File;

public class MainActivity extends Activity {
    // name of the map file in the external storage
    private static final String MAP_FILE = "berlin.map";

    private MapView mapView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        AndroidGraphicFactory.createInstance(this.getApplication());

        this.mapView = new MapView(this);
        setContentView(this.mapView);

        this.mapView.setClickable(true);
        this.mapView.getMapScaleBar().setVisible(true);
        this.mapView.setBuiltInZoomControls(true);
        this.mapView.setZoomLevelMin((byte) 10);
        this.mapView.setZoomLevelMax((byte) 20);

        // create a tile cache of suitable size
        TileCache tileCache = AndroidUtil.createTileCache(this, "mapcache",
                mapView.getModel().displayModel.getTileSize(), 1f,
                this.mapView.getModel().frameBufferModel.getOverdrawFactor());

        // tile renderer layer using internal render theme
        MapDataStore mapDataStore = new MapFile(new File(Environment.getExternalStorageDirectory(), MAP_FILE));
        TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore,
                this.mapView.getModel().mapViewPosition, AndroidGraphicFactory.INSTANCE);
        tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.DEFAULT);

        // only once a layer is associated with a mapView the rendering starts
        this.mapView.getLayerManager().getLayers().add(tileRendererLayer);

        this.mapView.setCenter(new LatLong(52.517037, 13.38886));
        this.mapView.setZoomLevel((byte) 12);
    }

    @Override
    protected void onDestroy() {
        this.mapView.destroyAll();
        AndroidGraphicFactory.clearResourceMemoryCache();
        super.onDestroy();
    }
}

我总是收到错误,

Error:(16, 37) error: cannot find symbol class InternalRenderTheme

Error:(50, 45) error: cannot find symbol variable InternalRenderTheme

所以这是我第一次尝试在我的项目中集成库。我只这样做,我没有从存储库下载任何内容或复制任何内容。我必须下载mapforge还是这个错误意味着什么?

最佳答案

我的决定是添加到应用程序的 build.gragle

compile 'org.mapsforge:mapsforge-themes:0.8.0'

关于android - Mapsforge InternalRenderTheme 缺失错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45559767/

相关文章:

android - OSM Magsforge(离线) map 中点和路径之间的最短距离

java - 如何使用 SharedPreferences 保存标记

android - Mapsforge 0.4.0 和 Eclipse 出现 NoClassDefFoundError

php - 无法重定向到 MainActivity 屏幕

android - 删除 Android 工具栏抽屉导航选项

android - Android Studio Linter 是否提供查找默认 XML 布局值的选项?

android - 错误类型 3 : Activity Class {. ..} 不存在

Android ndk 链接在 libgnuSTL_shared.so 上失败

java - Mapsforge 最简单的 map 查看器 - map 未使用默认主题渲染

leaflet - 在 Web 项目中使用 Android 项目中的 map.osm 和 osmarender.xml