Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Integrating Open Street Map in Android application


Published on

Published in: Technology, News & Politics
  • It is similar to CLOUDEMADE ??
    Are you sure you want to  Yes  No
    Your message goes here

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
  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 oid104jar.htm 2. slf4j-android-1.5.8.jar which can be downloaded from 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.