8-26 Oracle Fusion Middleware Users Guide for Oracle MapViewer
8.5.1 Creating One or More Map Tile Layers
For each map tile layer displayed on the client side that is served by MapViewer, you must create the corresponding map tile layer on the MapViewer server side. For
example, for the sample application described in Section 8.1.2
, you must create a map tile layer on the server side to display oceans, county boundaries, cities and highways
as a map tile layer on the client. However, if the tile layer is a custom or built-in eternal tile layer, you do not need to define the tile layer on the server side.
Before you can create a map tile layer, you must ensure that the map source from which the map tiles images are to be rendered is ready. If the map tile images are
rendered based on map data stored in the database, you must create a MapViewer base map that consists of a set of predefined themes. You can create the base map
using the Map Builder tool, which is described in
Chapter 9 . If the map tiles images
are rendered by an external map provider, you must write a map source adapter that can fetch map images from the external server using the tile image definition specified
by the map tile server.
When the map source is ready, you can create the map tile layer using the MapViewer administration page, as described in
Section 1.5.3 . When you create the map tile layer,
you must provide proper coordinate system definition, map source definition internal or external, and zoom level definition number of zoom levels and map scales.
After you create the map tile layer, you can test it by using a JavaServer Page JSP demo application shipped with MapViewer. The JSP demo application can be accessed
at http:host:portmapviewerfsmcomaps.jsp. Based on your input, this application can display maps served by any map tile layer defined with the
MapViewer instance.
8.5.2 Defining FOI Metadata
If your application needs to display dynamic features based on database query results as theme-based FOI layers, you must create a predefined MapViewer theme for each
theme-based FOI layer. If your application needs to display individual dynamic features as user-defined FOIs, you must define the rendering style or styles used by
the FOI server to render the FOI images. You can use the Map Builder tool described in
Chapter 9 to create predefined themes and rendering styles.
8.5.3 Creating the Client Application
Oracle Maps client applications running inside Web browsers are pure HTML and JavaScript pages that do not require any plug-ins. Therefore, you can build the
application using any Web technology that delivers content as pure HTM. Such technologies include JavaServer Pages, Java Servlets, ASP, and .NET C. This section
discusses client application development only in pure HTML format, but you can easily apply this information to other Web technologies.
As shown in Example 8–1
in Section 8.1.2
, the source code for an Oracle Maps application is typically packaged in an HTML page, which consists of the following
parts:
■
A script element that loads the Oracle Maps client library into the browser JavaScript engine. In
Example 8–1 , this element is:
script language=Javascript src=jslibloadscript.jsscript
■
An HTML DIV element that is used as the map container in the Web page. The size and positioning of the DIV element can be customized to suit your needs. In
Example 8–1 , this element is:
Oracle Maps 8-27
div id=map style=left:10; top:60;width: 600px; height: 500pxdiv
■
JavaScript code that creates and initializes the map client instance. It creates the map client instance, sets up the initial map content map tile layer, FOI layers, and
so on, sets the initial map center and zoom level, implements application-specific logic, displays the map, and implements other application-specific logic.
This code should be packaged inside a JavaScript function, which is executed when the HTML page is loaded from the server to the client Web browser. In
Example 8–1 , this function is named on_load_mapview:
function on_load_mapview {
var baseURL = http:+document.location.host+mapviewer; Create an MVMapView instance to display the map
var mapview = new MVMapViewdocument.getElementByIdmap, baseURL; Add a map tile layer as background.
mapview.addMapTileLayernew MVMapTileLayermvdemo.demo_map; Add a theme-based FOI layer to display customers on the map
var themebasedfoi = new MVThemeBasedFOIthemebasedfoi1,mvdemo.customers; themebasedfoi.setBringToTopOnMouseOvertrue;
mapview.addThemeBasedFOIthemebasedfoi; Set the initial map center and zoom level
mapview.setCenterMVSdoGeometry.createPoint-122.45,37.7706,8307; mapview.setZoomLevel4;
Add a navigation panel on the right side of the map mapview.addNavigationPaneleast;
Add a scale bar mapview.addScaleBar;
Display the map. mapview.display;
}
This function is specified in the onload attribute of the body element, so that it is executed after the Web page is loaded. In
Example 8–1 , this code is as follows:
body onload= JavaScript:on_load_mapview
■
Additional HTML elements and JavaScript code implement other application-specific user interfaces and control logic. In
Example 8–1 in
Section 8.1.2 , a JavaScript function setLayerVisible is implemented to show or
hide the theme-based FOI layer when the user checks or unchecks the Show customers
check box. The setLayerVisible function is coded as follows: function setLayerVisiblecheckBox
{ Show the theme-based FOI layer if the check box is checked
and hide the theme-based FOI layer otherwise. ifcheckBox.checked
themebasedfoi.setVisibletrue ; else
themebasedfoi.setVisiblefalse; }
This function is specified in the onclick attribute of the INPUT element that defines the check box, so that it is executed whenever the user clicks on the check
box. In Example 8–1
, this code is as follows: INPUT TYPE=checkbox onclick=setLayerVisiblethis checkedShow customers
8-28 Oracle Fusion Middleware Users Guide for Oracle MapViewer
8.6 Built-in Map Tile Layers Google Maps and Bing Maps