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, otherwise so many questions ended without proper conclusion about "HOW"..!
Is there any proper blog/site or document that can a fresher can refer?
The most basic way to use OpenStreetMap on your Android device is to open https://www.openstreetmap.org/ in a Web browser such as Chrome. The website is optimized for small screens such as those found on many Android phones; however, the slippy map is limited to basic gestures such as drag-to-pan and pinch-to-zoom.
With OSM, map data for the whole planet can be downloaded and used completely offline. Google Maps can only cache small region and generally can not work without an Internet connection. OSM dataset can be used to large-scale geocoding, routing and analysis, which would be impossible using Google Maps.
Pan and zoom the map to the area that you wish to edit. You can pan by holding the left mouse button and dragging the map to your desired area. Click on the small arrow next to Edit. Then click Edit with iD (in-browser editor).
I don't know of any tutorials but here's the code I wrote for a minimal example using Osmdroid.
// This is all you need to display an OSM map using osmdroid
package osmdemo.demo;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;
import android.app.Activity;
import android.os.Bundle;
public class OsmdroidDemoMap extends Activity {
private MapView mMapView;
private MapController mMapController;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.osm_main);
mMapView = (MapView) findViewById(R.id.mapview);
mMapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
mMapView.setBuiltInZoomControls(true);
mMapController = (MapController) mMapView.getController();
mMapController.setZoom(13);
GeoPoint gPt = new GeoPoint(51500000, -150000);
mMapController.setCenter(gPt);
}
}
/* HAVE THIS AS YOUR osm_main.xml
---------------------------------------------------------- XML START
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<org.osmdroid.views.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true" />
</LinearLayout>
---------------------------------------------------------- XML END
Include slf4j-android-1.5.8.jar and osmdroid-android-4.1.jar in the build path
(Google search for where to get them from)
*/
Note that you must now use the latest version (4.1) to avoid getting blocked from downloading tiles from OSM.
Also note that they are moving their repositries to Github and the process isn't complete yet. This page downloads holds the links for the jars
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With