简体   繁体   English

打开街道地图工作离线android

[英]Open Street Map working offline android

I am a newbie to Open Street Map. 我是Open Street Map的新手。 I made some research and found that we can download and store the map into a folder. 我做了一些研究,发现我们可以将地图下载并存储到一个文件夹中。 But i didn't find any tutorial or sample that provides offline Open Street Map. 但我没有找到任何提供离线Open Street Map的教程或示例。 Can someone provide a step by step tutorial, a guide to implement offline open street map please. 有人可以提供一步一步的教程,请执行离线开放街道地图的指南。 I am following this example http://android-coding.blogspot.com/2012/06/example-of-implementing-openstreetmap.html but now i want to make it available when there is no connection. 我正在关注此示例http://android-coding.blogspot.com/2012/06/example-of-implementing-openstreetmap.html但现在我想在没有连接时使其可用。

Like in the tutorial you mentionned you can use osmdroid library: https://code.google.com/p/osmdroid/ 就像你提到的教程一样,你可以使用osmdroid库: https//code.google.com/p/osmdroid/

There's a good explanation of how osmdroid works with offline maps here: https://stackoverflow.com/a/8286276/891479 这里有一个很好的解释osmdroid如何使用离线地图: https ://stackoverflow.com/a/8286276/891479

Use MapTileProviderBasic in your app. 在您的应用中使用MapTileProviderBasic。 Some examples here: http://www.androidadb.com/class/ma/MapTileProviderBasic.html 这里有一些例子: http//www.androidadb.com/class/ma/MapTileProviderBasic.html

To generate your offline maps in osmdroid format use Mobile Atlas Creator: http://mobac.sourceforge.net/ 要以osmdroid格式生成离线地图,请使用Mobile Atlas Creator: http ://mobac.sourceforge.net/

You can choose the source of the maps and the output format. 您可以选择地图的来源和输出格式。 Once generated, put your maps atlas in zip format into your "/osmdroid/map" directory. 生成后,将您的地图图册以zip格式放入“/ osmdroid / map”目录。

Hope it will help! 希望它会有所帮助!

I have found this tutorial that explains all things you need step by step. 我找到了这个教程 ,一步一步地解释了你需要的所有东西。

In brief: 简单来说:

1- You must download map tiles using Mobile Atlas Creator . 1-您必须使用Mobile Atlas Creator下载地图图块。 I have explained the steps HERE 我在这里解释了这些步骤

2- Move the resulting zip-file to /mnt/sdcard/osmdroid/ on your device. 2-将生成的zip文件移动到设备上的/ mnt / sdcard / osmdroid /。

3- Adding osmdroid-android-XXX.jar and slf4j-android-1.5.8.jar into build path your project 3-将osmdroid-android-XXX.jarslf4j-android-1.5.8.jar添加到构建路径中你的项目

4- Adding MapView: You can add a MapView to your xml layout 4-添加MapView:您可以将MapView添加到xml布局中

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

Or create a MapView programmatically: 或者以编程方式创建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;
}

Hope it Helps ;) 希望能帮助到你 ;)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM