Open Street Map working offline android

孤人 提交于 2019-12-17 22:51:46

问题


I am a newbie to 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. 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.


回答1:


Like in the tutorial you mentionned you can use osmdroid library: 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

Use MapTileProviderBasic in your app. Some examples here: http://www.androidadb.com/class/ma/MapTileProviderBasic.html

To generate your offline maps in osmdroid format use 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.

Hope it will help!




回答2:


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. I have explained the steps HERE

2- Move the resulting zip-file to /mnt/sdcard/osmdroid/ on your device.

3- Adding osmdroid-android-XXX.jar and slf4j-android-1.5.8.jar into build path your project

4- Adding MapView: You can add a MapView to your xml layout

<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:

@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 ;)




回答3:


MOBAC(Mobile Atlas Creator) is blocked now for using OSM You can see here



来源:https://stackoverflow.com/questions/14794705/open-street-map-working-offline-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!