Open Street Maps in Android--Part 1
Open Street Maps (Osmdroid) is mainly used as an alternative for Google Maps.The main Advantage of
this is the use of offline access.
To use this map, we requires
1: Latest osmdroid jar (osmdroid-android-3.0.8.jar)
2: slf4j-android-1.5.8.jar
you can check out the project from
https://code.google.com/p/osmdroid/
Open Street Maps (Osmdroid) is mainly used as an alternative for Google Maps.The main Advantage of
this is the use of offline access.
To use this map, we requires
1: Latest osmdroid jar (osmdroid-android-3.0.8.jar)
2: slf4j-android-1.5.8.jar
you can check out the project from
https://code.google.com/p/osmdroid/
Sample Code:
<?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
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true" />
</LinearLayout>
OsmdroidDemoMap.java
public class OsmdroidDemoMap extends Activity {
private MapView mMapView;
private MapController mMapController;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapView map = (MapView) findViewById(R.id.map);
map.setTileSource(TileSourceFactory.MAPNIK);
map.setBuiltInZoomControls(true);
map.setMultiTouchControls(true);
map.getController().setZoom(16);
map.getController().setCenter(new GeoPoint(30266000, -97739000));
}
}
Manifest Permissions
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
0 comments: