Comparing GoogleMap and Mapquest Integration on Android

2 min read

There are many blogs around the web for android and MapQuest implementation, here I am trying to summarize the benefits and drawback of them.

google-maps-icon
Ways to implement maps to show directions/routes

  1. Opening existing native app
  2. Native implementation
  3. WebView implementation

Opening existing native app:

Android Intent class can be used to open existing application by class name. Using Intent.ACTION_VIEW we can open map or browser to show location/directions. Native Google map is faster than web or webview map on Mobile. Problem here may be, map will not be embedded into our custom apps. It will open external an app.
Here is the sample code:
[source language=”java”]
void drawRoute(Location src_location,Location dest_location) {
String geoUriString = “http://maps.google.com/maps?saddr=”
+ src_location.getLatitude() + “,” + src_location.getLongitude()
+ “&daddr=” +dest_location.getLatitude() + “,” + dest_location.getLongitude();
Intent navigation = new Intent(Intent.ACTION_VIEW,
Uri.parse(geoUriString));
navigation.setClassName(“com.google.android.apps.maps”,
“com.google.android.maps.MapsActivity”);
startActivity(navigation);
}
[/source]
Complete snippet is available at https://gist.github.com/sivakumarbdu/4680530#file-googlemap_webview
Native implementation:
When application needs embedded map module, this will be useful. Google provide API to access directions/routes and several other functions.

android_awesome

Also Google provide nice documentation for map implementation at https://developers.google.com/maps/documentation/android/
If you want to try the direct source, please check the snippet available at https://gist.github.com/4680612
WebView implementation
Its very easy way to embedded map into custom apps but performance will be very slow compared to native implementation. We can render maps.google.com to show locations with proper parameter.
Source snipped available https://gist.github.com/4680628
 
[source language=”java”]
void setupMapView() {
setContentView(R.layout.activity_main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
void drawRoute(Location location) {
selected_lat = Double.parseDouble(intent.getStringExtra(“lat”));
selected_lon = Double.parseDouble(intent.getStringExtra(“lon”));
ArrayList all_geo_points = Directions.getDirections(
location.getLatitude(), location.getLongitude(), selected_lat,
selected_lon);
mapOverlays.add(new MyOverlay1(all_geo_points));
controller.setZoom(12);
mapView.invalidate();
}
[/source]
MapQust Map
Other good alternate for Google map is MapQuest. MapQuest can also be implemented as native app or as Webview.

mapquest
MapQuest got good data points for USA but not for Asian countries. It provides various class to help developer, especially RouteManager will be more useful stuff on drawing routes between two destinations. MapQuest provide good documentation at http://developer.mapquest.com/
MapQuest Javascript API can be found at http://developer.mapquest.com/web/documentation/sdk/javascript/v7.0 . Implementation of MapQuest is similar to Google map with few differences. Libraries and class names will be from MapQuest jar rather than Google map.

 
 
[source language=”java”]
import com.google.android.maps.Overlay;
import com.mapquest.android.maps.DefaultItemizedOverlay;
import com.mapquest.android.maps.GeoPoint;
import com.mapquest.android.maps.ItemizedOverlay;
import com.mapquest.android.maps.MapActivity;
import com.mapquest.android.maps.MapView;
import com.mapquest.android.maps.OverlayItem;
import com.mapquest.android.maps.RouteManager;
import com.mapquest.android.maps.RouteResponse;
import com.mapquest.android.maps.ServiceResponse.Info;
import com.mapquest.android.Geocoder;
[/source]
[source language=”java”]
void setupMapView() {
setContentView(R.layout.map);
map = (MapView) findViewById(R.id.map);
map.setBuiltInZoomControls(true);
}
[/source]
Source snippet available at https://gist.github.com/4680672
Images credits goes to :
http://www.thebiblescholar.com/android_awesome.jpg
http://ecx.images-amazon.com/images/I/31aWEVpfCiL._SL500_AA300_.png
http://corrupteddevelopment.com/wp-content/uploads/2012/02/google-maps-icon.jpg

Related posts:

One Reply to “Comparing GoogleMap and Mapquest Integration on Android”

Leave a Reply

Your email address will not be published. Required fields are marked *