Integrate OpenStreetMap in android application
In this post, i am going to show you a simplest way to integrate the OpenStreeMap in android application. So without going into deep explanation let's create sample app that show a user current location on the map.
Step 1 :
Add the osm library in your build.gradle(app level)
implementation 'org.osmdroid:osmdroid-android:6.0.0'
Step 2 :
Add permissions in the AndroidManifest.xml file
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Step 3 :
Create a fragment or activity according to your wish and in my case i have created a fragment. Do the copy and paste of below code into your project
Step 1 :
Add the osm library in your build.gradle(app level)
implementation 'org.osmdroid:osmdroid-android:6.0.0'
Step 2 :
Add permissions in the AndroidManifest.xml file
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Step 3 :
Create a fragment or activity according to your wish and in my case i have created a fragment. Do the copy and paste of below code into your project
thank.can we have the java code?
ReplyDeletenot working!
ReplyDeletenot working
ReplyDeletei implemented but it don't work what's the problem i can't see the map
ReplyDelete