How to create map tiles from OpenStreetMap offline, display it on Android?

前端 未结 3 568
既然无缘
既然无缘 2020-12-02 11:13

What I want is to display a simple offline map using OpenStreetMap. I cannot find in the web the right tools to create map tiles and use it to display a map in Android. I ha

3条回答
  •  情深已故
    2020-12-02 11:37

    Here is a step by step solution:

    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

    
    

    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;
    }
    

    Don't forget to add these permissions to your Manifest:

     
    
    
    
    
    
    

    This is a good Sample Project. Hope it Helps ;)

    Important

    As @Scai mentioned: recently Open Street Map announced that this tool is not good and had some problems:

    This tool results in heavy traffic for the OSM tile servers and is likely to be blocked. Please don't use it.

提交回复
热议问题