12

我是开放街道地图的新手。我做了一些研究,发现我们可以下载地图并将其存储到一个文件夹中。但我没有找到任何提供离线开放街道地图的教程或示例。有人可以提供分步教程,请提供实现离线开放街道地图的指南。我正在关注这个例子http://android-coding.blogspot.com/2012/06/example-of-implementing-openstreetmap.html但现在我想让它在没有连接时可用。

4

3 回答 3

6

就像在您提到的教程中一样,您可以使用 osmdroid 库: https ://code.google.com/p/osmdroid/

这里有一个很好的解释 osmdroid 如何与离线地图一起工作: https ://stackoverflow.com/a/8286276/891479

在您的应用程序中使用 MapTileProviderBasic。这里的一些例子: http ://www.androidadb.com/class/ma/MapTileProviderBasic.html

要生成 osmdroid 格式的离线地图,请使用 Mobile Atlas Creator: http ://mobac.sourceforge.net/

您可以选择地图的来源和输出格式。生成后,将您的地图集以 zip 格式放入“/osmdroid/map”目录。

希望它会有所帮助!

于 2013-03-05T09:24:24.203 回答
4

我发现本教程逐步解释了您需要的所有内容。

简单来说:

1- 您必须使用Mobile Atlas Creator下载地图图块。我已经解释了这里的步骤

2- 将生成的 zip 文件移动到设备上的 /mnt/sdcard/osmdroid/。

3-将osmdroid-android-XXX.jarslf4j-android-1.5.8.jar 添加到项目的构建路径中

4- 添加 MapView:您可以将 MapView 添加到您的 xml 布局

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

或以编程方式创建 MapView:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    mResourceProxy = new ResourceProxyImpl(inflater.getContext().getApplicationContext());
    mMapView = new MapView(inflater.getContext(), 256, mResourceProxy);
    return mMapView;
}

希望能帮助到你 ;)

于 2015-08-23T06:33:37.847 回答
0

MOBAC(Mobile Atlas Creator)现在被阻止使用 OSM 你可以在这里看到

于 2017-08-10T13:36:16.923 回答