Integrating Open Street Map in Android application

8,696 views
8,328 views

Published on

Published in: Technology, News & Politics
1 Comment
5 Likes
Statistics
Notes
  • It is similar to CLOUDEMADE ??
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
8,696
On SlideShare
0
From Embeds
0
Number of Embeds
17
Actions
Shares
0
Downloads
245
Comments
1
Likes
5
Embeds 0
No embeds

No notes for slide

Integrating Open Street Map in Android application

  1. 1. Open Street MapIS GOOGLE MAP DEPRECATED?
  2. 2. Basic Ideas Open Street Map (OSM) is a free editable map. The maps are created using data from portable SAT NAV devices, aerial photography & simply from local knowledge. The real power of OSM is not default rendering, but the possibility to actually access the data behind this map rendering. And this is where it differs from Google maps, Bing Maps and Yahoo! Maps and various others. Let’s have a look to OSM at http://www.openstreetmap.org/
  3. 3. Why we are interested? From 1 January 2012, Google will charge for the Google Maps API service when more than the limit of 25,000 map "hits" are made in a day. Google is rumored to be charging $4 per 1,000 views in excess of the limit. These two points may be good enough to make us interested for hunting a free but reliable option.
  4. 4. Getting StartedLets Create a new Project in eclipse.
  5. 5. Getting StartedWe have to include two jar files. These are: 1. osmdroid-android-1.04.jar which can be downloaded from http://www.java2s.com/Code/Jar/o/Downloadosmdroidandr oid104jar.htm 2. slf4j-android-1.5.8.jar which can be downloaded from http://www.slf4j.org/android/ Download the jars by clicking the links above. Create a folder libs into the project & put thejars in the libs folder.
  6. 6. Add jars Add the jars by configuring java build path: Right click on project>Buils Path>Configure Build Path > Libraries > Add Jars & then select the jars from theProjects libs folder.
  7. 7. Add permissionsAdd the permissions to the manifest. <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" />
  8. 8. Create layout In main.xml, define the layout:
  9. 9. Override onCreate Now we are ready for some java coding. We Override the onCreate method of MyOpenStreetMapActivity:
  10. 10. Analyze onCreateLets analyze the onCreate method:1. We set the content view to main.2. We initialize the relative layout.3. We initialize the map view.4. We add the built in zoom control.5. We initialize the MyLocationOverlay Class with the context & mapview.6. We add the overlay to our map view.7. We add the map view to our relative layout.8. We set the zoom level.
  11. 11. Override onResume & onPause We override the onResume Method & myLocationOverlay is enabled to read the GPS location: We override the onPause method to disable the location listener:
  12. 12. Deployment Now we are ready to run our application. Here we are seeing a buttonNamed “Google Map”. LetsImplement some functionality toIt. Implement a google map tothis button which will toggle theMap to google map & shows theuser’s current location.

×