4.3 Using Google Maps

Applications can display Google Maps tiles as a built-in map tile layer, by creating and adding to the map window an instance of MVGoogleTileLayer .

Internally, the Oracle Maps client uses the official Google Maps API to display the map that is directly served by the Google Maps server.

To use the Google Maps tiles, your usage of the tiles must meet the terms of service specified by Google (see https://developers.google.com/readme/terms).

If you need to overlay your own spatial data on top of the Google Maps tile layer, see also Transforming Data to a Spherical Mercator Coordinate System.)

The following sections describe the two options for using built-in map tile layers.

4.3.1 Defining Google Maps Tile Layers on the Client Side

To define a built-in map tile layer on the client side, you need to create a MVGoogleTileLayer object, and add it to the MVMapView object. (As of Oracle Fusion Middleware Release 11.1.1.6, MVGoogleTileLayer uses the Google Maps Version 3 API by default.)

For example, to use Google tiles, add the Google tile layer to your map:

mapview = new MVMapView(document.getElementById("map"), baseURL);
tileLayer = new MVGoogleTileLayer() ;
mapview.addMapTileLayer(tileLayer);

In your application, you can invoke the method MVGoogleTileLayer.setMapType to set the map type to be one of the types supported by the map providers, such as road, satellite, or hybrid.

For usage examples and more information, see the JavaScript API documentation for MVGoogleTileLayer, and the tutorial demo Built-in Google Maps Tile Layer.

4.3.2 Defining the Built-In Map Tile Layers on the Server Side

You can define a built-in map tile layer (also called an external tile layer) on the server side in the metadata, and use it as a regular map visualization component tile layer on the client side. To define a built-in map tile layer on the server side, follow these steps:

  1. Log into the map visualization component administration page (explained in Logging in to the Map Visualization Component Administration Page).

  2. Select the Admin tab and clickCreate tile layer.

  3. For Tile Layer Type, choose Oracle Maps, Google Maps, HERE Maps, OpenStreet Maps, Tomtom Maps, or LocationBox Maps, and click Next.

  4. Provide a name for this external tile layer (such as GOOGLE_MAP), and select the data source where the tile layer definition is to be stored.

  5. Set the license key that you have obtained from the map provider and other relevant properties (details are available for specific external tile layers), and click Next.

  6. Review the XML Description of the external tile layer. You may click Previous to go to the previous page to make changes.

  7. Click Submit to create the tile layer.

After you have created the built-in map tile layer on the server side, you can use it like any other tile layer served by MapViewer. You do not need to add any <script> tag to load the external JavaScript library.

The following code snippetshows a Google Maps tile layer defined on the server side:

 var tileLayer = new OM.layer.TileLayer("google1", {
      dataSource:"mvdemo", 
      tileLayer:"GOOGLE_MAP"
      });
	
  map.addLayer(tileLayer) ;

Note:

Each built-in tile layer has its own specific properties. You may need to check with the service provider for requirements.

If Google Maps will be used, you may need to provide the following properties:

  • key: the key you obtained from Google Maps.

  • client: the client ID, an optional property you may obtain from Google Maps. The key property is still needed when the client ID is provided.

  • lib_url: the Google Maps API URL, for example: http://maps.google.com/maps/api/js?sensor=false. If not provided, a default value will be used.

  • version: the current API version is 3.

  • mapTyelList, a list of map types may be provided: MVGoogleTileLayer.TYPE_ROAD; MVGoogleTileLayer.TYPE_SHADED; MVGoogleTileLayer.TYPE_SATELLITE; MVGoogleTileLayer.TYPE_HYBRID.

  • mapTypeVisible, a Boolean true or false value to indicate whether to have the map type buttons be displayed for selecting map types.