If you are looking for a way to implement location based services within your android application without using the web services of Google, you might be interested in the CloudMade web services. These web services provide functions like geocoding, searching for objects which are close to a given coordinate, retrieving map tiles as images and even to create a full route from a start point via several transit points to an end point.
To provide these services, CloudMade relies on the collaborative OpenStreetMap (OSM) project which follows the same principles as Wikipedia to create a free map.
To ensure an easy usage of the web services, CloudMade provides several libraries for the iPhone and other programming languages. The provided Java API is using an old implementation of the Apache HTTP Client which makes it unusable for Android devices. That’s why I’ve created a port of the lightweight CloudMade Java API which can be used on android devices.
The core of this library is the com.appsolut.api.cloudmade.CMClient which hides the HTTP communication of the different calls from the developer. The methods within this class are well documented and I will only give short overview of the most important methods:
public GeoResults find(String query, int results, int skip, BBox bbox, boolean bboxOnly, boolean returnGeometry, boolean returnLocation)
This method provides the geocoding functionality:
public GeoResult findClosest(String object_type, Point point) throws ObjectNotFoundException
If you want to find a certain object which is close to a point you can use this method:
public byte getTile(double latitude, double longitude, int zoom, int styleId, int size)
This method will return a png image of a map tile. For example, this might return a tile which looks like the following:
public Route route(Point start, Point end, RouteType routeType, List<Point> transitPoints, RouteTypeModifier typeModifier, String lang, MeasureUnit units) throws RouteNotFoundException
Using this method it is possible to create a route.
There exists also an android test project which can be used to ensure that everything works fine. You can also take a look at the test cases to see an example of how to use the library.
You can download or browse the source code at our repository at Google Code (http://code.google.com/p/android-cloudmade-api/) or use svn to check it out.
For more information you can refer to the following links:
If you are having trouble with this port feel free to ask questions.
It is important that you create your own API key when you are using the CloudMade web services. Please refer to the CloudMade FAQ for more information on this topic.
by Kevin Kratzer