【问题标题】:osmdroid: How to load offline map from sdcard to MapViewosmdroid:如何将离线地图从 sdcard 加载到 MapView
【发布时间】:2016-04-20 11:52:57
【问题描述】:

我生成了一组地图,将其压缩为名称tiles.zip 并复制到sdcard/osmdroid 文件夹中。这里是atlas 设置和文件夹内容。

我使用了示例项目here。 它运行没有错误,但我的地图没有出现在MapView 中。这是 MainActivity 和布局:

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;


public class MainActivity extends AppCompatActivity {

    public static final GeoPoint BERLIN = new GeoPoint(52.516667, 13.383333);
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setClickable(true);
        mapView.setBuiltInZoomControls(true);
        mapView.setMultiTouchControls(true);
        mapView.setUseDataConnection(true);

       mapView.setTileSource(TileSourceFactory.MAPQUESTOSM);
       IMapController mapViewController = mapView.getController();
       mapViewController.setZoom(15);
       mapViewController.setCenter(BERLIN);


    }
}

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${packageName}.${activityClass}">

    <org.osmdroid.views.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clickable="true" />

</RelativeLayout>

正如我测试的那样,如果我解压缩地图并将它们添加为assets,地图会显示但顺序错误。

知道有什么问题吗? 谢谢

编辑1

这是我的日志:

【问题讨论】:

标签: android osmdroid


【解决方案1】:


1) 缩放级别为 15 的图块中有柏林吗?如果没有,请尝试将缩放级别设置为 1 或将地图中心更改为您所在的地区。
2) 你不需要在 MOBAC 中创建那么多层。只需选择您的区域、缩放级别并立即添加它。它可能会有所帮助。其他设置和我的项目一样

【讨论】:

  • 这可能是另一个问题,但根据应用程序日志(EDIT1),问题似乎是在读取目录期间。
  • @Behy 你的 android 清单文件中有这些权限吗? osmdroid wiki
  • 看来问题出在三星手机上。使用 Nexus 时没问题
猜你喜欢
  • 1970-01-01
  • 2011-11-29
  • 1970-01-01
  • 2016-10-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-12
  • 1970-01-01
相关资源
最近更新 更多