Using a WebView to access Google Maps

The BlackBerry Runtime for Android apps supports location-based intents to display Google Maps. Once triggered, these intents are converted into web intents that carry the corresponding URL for the Google Maps that are to be displayed in the browser.

The following intent URIs are supported:

geo:latitude,longitude
geo:latitude,longitude?z=zoom
geo:0,0?q=address+business+or+keywords

Instead of starting a location intent, you can create an instance of a WebView and load the URL of the Google Maps mobile website. You can add parameters to the URL, which allows you to use more functionality than is available using the Java-based Google Maps API.

The following sample demonstrates how you can create an instance of a WebView to display a mobile Google Maps URL with parameters in an Android app. The main activity of your app should contain the following lines in its onCreate() method:

@Override
public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      
      WebView webView = (WebView) findViewById(R.id.mywebview);
      webView.getSettings().setJavaScriptEnabled(true);
      webView.loadUrl("http://maps.googleapis.com/maps/api/staticmap?
       ll=36.97,%20-122&lci=bike&z=13&t=p&size=500x500&sensor=true");
}

For more information about the Google Static Maps API URL, see URL Parameters.

The following table highlights some of the differences in functionality between using the Google Maps Java API and using the URL parameters of Google Maps.

A Java-based mapping API library and Geo-coding API for Google Maps are not available for the BlackBerry Runtime for Android apps.

Feature

Google Maps Java API

URL Parameters of Google Maps

Available map types and customization

Road

Satellite

Custom projections

Road

Satellite

Hybrid

Terrain

UI controls

Zoom

Zoom

Query input field

Layers

Current location

Get Directions

Places

Overlays

Built-in overlay types are not available, but you can implement your own

Markers

Layers

Traffic

Bicycling

Traffic

Transit

YouTube

Wikipedia

Panoramio

Direction service

Not available

Source/destination query

Intermediate addresses

Travel mode (driving, bicycling, walking)

Unit systems

Departure and arrival times for transit

Geo-coding service

Not part of the mapping library. Can be done using a separate Google service for Android (not available in BlackBerry Runtime for Android apps)

Keyword query support

Nearby location

Search mode (businesses, mapped webpages, real estate, and so forth)



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus