4-4 Oracle Fusion Middleware Users Guide for Oracle MapViewer
4.3.1 Creating the MapViewer Bean
The first step in any planned use of the MapViewer bean is to create the bean, as shown in the following example:
import oracle.lbs.mapclient.MapViewer; MapViewer mv = new MapViewerhttp:my_corp.com:8888mapvieweromserver;
The only parameter to the constructor is a URL to an actual MapViewer service. Unless you change it to something else using setServiceURL, the MapViewer
service at this URL will receive all subsequent requests from this bean. When a MapViewer bean is created, it contains an empty current map request. There are a few
parameters in the current request that are initialized with default values, such as the width and height of the map image and the background color for maps. These default
values are explained in the XML API element and attribute descriptions in
Chapter 3 .
4.3.2 Setting Up Parameters of the Current Map Request
As explained in Chapter 3
, a map request can have many parameters that affect the final look of the generated map image. When you use the MapViewer JavaBean, such
parameters can be set through a group of methods whose names start with set. Many of these parameters have a corresponding method that starts with get. For example,
setAntiAliasing sets antialiasing on or off, and getAntiAliasing returns the current antialiasing setting.
The methods for setting parameters of the current map request include the following:
■
setAntiAliasingboolean aa specifies whether or not the map should be rendered using the antialiasing technique.
■
setBackgroundColorjava.awt.Color bg sets the background color for the map to be generated.
■
setBackgroundImageURLjava.lang.String bgImgUrl sets the URL for the background image to be rendered in the map.
■
setBaseMapNamejava.lang.String name sets the name of the base map to be rendered before any explicitly added themes.
■
setBoundingThemesString[] themeNames, double borderMargin, boolean preserveAspectRatio sets the bounding themes for the current
map request. Any previous center point and box settings will be cleared as a result of calling this method.
■
setBoxdouble xmin, double ymin, double xmax, double ymax sets the map query window box in the data coordinate space. Any previous center
point and size settings will be lost as a result of calling this method.
■
setCenterdouble cx, double cy sets the center point for this map request. The coordinates must be in the user data space.
■
setCenterAndSizedouble cx, double cy, double size sets the map center and size for the map to be generated. All data must be in the user data
space.
■
setDataSourceNamejava.lang.String name sets the name of the data source to be used when loading data for the map.
■
setDefaultStyleForCenterjava.lang.String defRenderStyleName, java.lang.String defLabelStyleName, java.lang.String
defLabel, double[] defRadii sets the default styling and labeling information for the center point of the map. Each subsequent map generated will
MapViewer JavaBean-Based API 4-5
have its center point rendered and optionally labeled with circles of the specified radii.
■
setDeviceSizejava.awt.Dimension dsz sets the image dimension of the map to be generated.
■
setFullExtent tells the MapViewer server not to impose any center and size restriction for the next map request. This effectively removes the current map
center and size settings. The resulting map will be automatically centered at the full extent of all features being displayed.
■
setImageFormatint f sets the image format that MapViewer should use when generating the map. For JSP pages, you should always set it to FORMAT_
PNG_URL or FORMAT_GIF_URL.
■
setImageScalingboolean is specifies whether images in an image theme should automatically be rescaled to fit the current query window. The default is
TRUE. If you specify FALSE, the images will be rendered without any scaling by MapViewer; however, the original query window may be slightly modified to
allow other vector themes to overlay properly with the images. In all cases, the map center is not changed.
■
setMapLegendjava.lang.String legendSpec sets the map legend in XML format to be plotted with current map. The legend must be specified in the
legendSpec parameter, in the format for the legend element that is documented in
Section 3.2.11 .
■
setMapLegendjava.lang.String fill, java.lang.String fillopacity, java.lang.String stroke, java.lang.String
profile, java.lang.String position, java.lang.String fontFamily, java.lang.String[][][] legenddata sets the map
request legend to be plotted with current map. The legenddata attribute contains the legend items, and its structure is String [x][y][z]
legenddata, where x is the number of legend columns, y is the number of column items, and z is the legend attributes index 0 = legend text, index 1 = style
name, index 2 = is title or not, index 3 = tab, index 4 = is separator or not.
■
setMapLegendjava.lang.String fill, java.lang.String fillopacity, java.lang.String stroke, java.lang.String
profile, java.lang.String position, java.lang.String[][][] legenddata is the same as the preceding method, but without the fontFamily
attribute.
■
setMapRequestSRIDint d sets the map request output SRID, which must match an SRID value in the MDSYS.CS_SRS table. Themes whose SRID value is
different from the map request SRID will be automatically converted to the output SRID if the theme SRID is not null or not equal to 0. If no map request SRID is
defined equal to zero, MapViewer will use the theme’s SRID as reference, but no transformation will be performed if the themes have different SRID values.
■
setMapResultFileNameString mapFile sets the name of the resulting map image file on the server side. If the name is set to null the default,
MapViewer will generate map image files based on the prefix omsmap and a counter value. You do not need to specify the extension .gif or .png when
specifying a custom map file name.
■
setMapTitlejava.lang.String title sets the map title for the map to be generated.
■
setServiceURLjava.lang.String url sets the MapViewer service URL.
4-6 Oracle Fusion Middleware Users Guide for Oracle MapViewer
■
setSizedouble size sets the height size in the user data space for the map to be generated.
■
setShowSVGNavBarboolean s specifies whether or not to show the built-in SVG navigation bar. The default value is TRUE that is, show the navigation bar.
■
setSVGOnClickjava.lang.String onClick sets the onClick function for an SVG map. The onClick function is a JavaScript function defined in the
Web page in which the SVG map is embedded. The onClick function is called whenever the SVG map is clicked if both theme feature selection and window
selection are disabled. For information about using JavaScript functions with SVG maps, see
Appendix B .
■
setSVGShowInfoboolean info specifies whether or not to display hidden information when the mouse moves over features for which hidden information is
provided. If its value is TRUE the default, hidden information is displayed when the mouse moves over such features; if it is set to FALSE, hidden information is
not displayed when the mouse moves over such features. Regardless of the value, however, hidden information is always rendered in an SVG map; this method
only controls whether hidden information can be displayed.
■
setSVGZoomFactordouble zfactor sets the zoom factor for an SVG map. The zoom factor is the number by which to multiply the current zoom ratio for
each integer increment a zoomin operation in the zoom level. The inverse of the zoom factor value is used for each integer decrement a zoomout operation in the
zoom level. For example, if the zfactor value is 2 the default, zooming in from zoom level 4 to 5 will enlarge the detail by two; for example, if 1 inch of the map at
zoom level 4 represents 10 miles, 1 inch of the map at zoom level 5 will represent 5 miles. The zoom ratio refers to the relative scale of the SVG map, which in its
original size zoom level 0 has a zoom ratio of 1.
■
setSVGZoomLevelsint zlevels sets the number of zoom levels for an SVG map.
■
setSVGZoomRatiodouble s sets the zoom factor to be used when an SVG map is initially loaded. The default value is 1, which is the original map size
zoom level 0. Higher zoom ratio values show the map zoomed in, and lower values show the map zoomed out.
■
setWebProxyjava.lang.String proxyHost, java.lang.String proxyPort sets the Web proxy to be used when connecting to the MapViewer
service. This is needed only if there is a firewall between the Web service and this bean.
You can remove the map legend from the current map request by calling the deleteMapLegend method.
4.3.3 Adding Themes or Features to the Current Map Request