How to use OSM map in an android application.? Is there any tutorial to learn about using OSM in android.?

后端 未结 5 612
后悔当初
后悔当初 2021-01-31 11:06

I am searching for a tutorial/manual or steps to include Open street map into my android application. All I found is either a big project with lot more functionality on it, othe

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-31 11:40

    One mistake that people using Google Maps like service make is that they treat OpenStreetMap as just map tile provider. You need to know that OpenStreetMap is actually a big free editable wiki geodatabase and there are three different ways you can use this database.

    1. You can make tools to write to this database. There is REST Api https://wiki.openstreetmap.org/wiki/API_v0.6 . This is what you use if you have to make changes to the database. This is the least common use case but is most thoroughly documented. The API is main OSM API and can be used to download data as well but it is not the recommended way to download OSM data.

    2. Next you can read data from this database. The best way to do is to download planet extracts https://wiki.openstreetmap.org/wiki/Planet.osm and smaller extracts hosted by geofabrik http://download.geofabrik.de/. If you want to make more specific queries, best options could be Overpass API https://wiki.openstreetmap.org/wiki/Overpass_API.

    3. Finally there are a range of service that are built on top of OSM data like (map tiles, routing, POI search, geocoding). This is most probably what you are looking for there are lot of options for this. For Android a good complete solution is Mapbox https://www.mapbox.com/android-docs/map-sdk/overview/ . The great thing about mapbox android sdk is that they provide everything like map tiles, routing, POI search, geocoding, offline maps and even live traffic using one service. Also you can follow the above link and look at tutorials and sample code. One bad thing is that you will need to use mapbox service and there is a risk of vendor lock in, but most of mapbox products are open source. If you work a little hard you should be able to piece together other solutions for yourself as well.

    Hope this helps.

提交回复
热议问题