6.52.  < rich:virtualEarth >

6.52.1. Description

The component presents the Microsoft Virtual Earth map in the JSF applications.

<rich:virtualEarth> component

Figure 6.104.  <rich:virtualEarth> component


6.52.2. Key Features

  • Presents the Microsoft Virtual Earth map functionality

  • Highly customizable via attributes

  • No developers JavaScript writing is needed to use it on a pages

Table 6.213. rich : virtualEarth attributes

Attribute NameDescription
bindingThe attribute takes a value-binding expression for a component property of a backing bean
dashboardSizeInitial map type. The possible values are Normal,Small,Tiny. The default value is Normal
idEvery component may have a unique id that is automatically created if omitted
latInitial latitude coordinate in degrees, as a number between -90 and +90
lngInitial longitude coordinate in degrees, as a number between -180 and +180
mapStyleNavigation control size. The possible values are Road,Aerial,Hybrid,Birdseye. The default value is Road
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onLoadMapJavaScript code invoked just after the Virtual Earth object is initiated.
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
renderedIf "false", this component is not rendered
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
varThe JavaScript variable that is used to access the Virtual Earth API. If you have more than one Virtual Earth components on the same page, use individual key for each of them. The default variable name is "map" (without quotes)
versionVirtual earth version, default - "6"
zoomInitial zoom level as a number between 1 and 18. The default value is 17

Table 6.214. Component identification parameters

NameValue
component-typeorg.richfaces.VirtualEarth
component-classorg.richfaces.component.html.HtmlVirtualEarth
component-familyorg.richfaces.VirtualEarth
renderer-typeorg.richfaces.VirtualEarthRenderer
tag-classorg.richfaces.taglib.VirtualEarthTag

6.52.3. Creating the Component with a Page Tag

To create the simplest variant on a page use the following syntax:

Example:


...
    <rich:virtualEarth lat="..." lng="..."/>
...

6.52.4. Creating the Component Dynamically Using Java

Example:


import org.richfaces.component.html.HtmlVirtualEarth;
...
HtmlVirtualEarth myMap = new HtmlVirtualEarth();
...

6.52.5. Details of Usage

Here are the main settings of initial rendering performed with a component map that are accessible with the following attributes:

  • "zoom" defines an approximation size (boundary values 1-18)

  • "lat" specifies an initial latitude coordinate in degrees, as a number between -90 and +90

  • "lng" specifies an initial longitude coordinate in degrees, as a number between -180 and +180

  • "dashboardSize" specifies a type of a rendered map (Normal, Small, Tiny)

For example, the city of Paris is shown after rendering with the following initial settings: "lat" = 48.833, "lng" = 2.40 and "zoom" = 11.

<rich:virtualEarth> initial rendering

Figure 6.105.  <rich:virtualEarth> initial rendering


Code for this example is placed below:

Example:


...
    <rich:virtualEarth  style="width:800px;" id="vm" lat="48.833" lng="2.40" 
                                     dashboardSize="Normal"  zoom="11" mapStyle="Hybrid" var="map" />
...

To set all these parameters and perform some activity (Zoom In/Out etc.) is possible with your JavaScript, i.e. declare a name of an object on a map in the "var" attribute and then call the object directly with API Microsoft Virtual Earth map.

For example, to approximate a map for "var" = "map" declared inside the component, call map.ZoomIn() on an event.

Moreover, to add e.g. some JavaScript effects, events defined on it are used.

  • onmouseover

  • onclick

  • onmouseout

  • etc.

Note

Virtual Earth does not support XHTML format of the page. Thus, if you use Facelets and JSF 1.2, do not forget to put the following tags somewhere on the page:


...
<f:view contentType="text/html">...</f:view>
...

6.52.6. Look-and-Feel Customization

<rich:virtualEarth> component isn't tied to skin parameters, as there is no additional elements on it, except the ones provided with Virtual Earth map.

6.52.7. Definition of Custom Style Classes

Table 6.215. Classes names that define a component appearance

Class nameDescription
rich-virtualEarthDefines styles for a wrapper <div> element of a component

In order to redefine styles for all <rich:virtualEarth> components on a page using CSS, it's enough to create class with the same name and define necessary properties in it.

To change styles of particular <rich:virtualEarth> components, define your own style class in the corresponding <rich:virtualEarth> attribute.

6.52.8. Relevant Resources Links

Here you can found additional information about Microsoft Virtual Earth map.