Create new RichFaces Documentation Jira issue

This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.orgCommunity Documentation

6.14.3.  < rich:gmap > available since 3.0.0

Component that presents the Google map in the JSF applications.


Table 6.576. rich : gmap attributes

Attribute Name Description
binding JSF: The attribute takes a value-binding expression for a component property of a backing bean
enableContinuousZoomEnables continuous smooth zooming for selected browsers. Default value is "false".
enableDoubleClickZoomEnables zooming in by a double click. Default value is "false".
enableDraggingEnables a map dragging with the mouse. Default value is "true".
enableInfoWindowEnables Info Window. Default value is "true".
gmapKeyGoogle Map key. A single Map API key is valid for a single "directory" on your web server. Default value is "internal".
gmapVarThe JavaScript variable that is used to access the Google Map API. If you have more than one Google Map components on the same page, use individual key for each of them. The default variable name is "map" (without quotes).
id JSF: Every component may have a unique id that is automatically created if omitted
latInitial latitude coordinate in degrees, as a number between -90 and +90. Default value is "37.9721046".
lngInitial longitude coordinate in degrees, as a number between -180 and +180. Default value is "-122.0424842834".
localeUsed for locale definition. Default value is "getDefaultLocale()".
mapTypeInitial map type. The possible values are "G_NORMAL_MAP", "G_SATELLITE_MAP", "G_HYBRID_MAP". Default value is "G_SATELLITE_MAP".
onclick DHTML: The client-side script method to be called when the element is clicked
ondblclick DHTML: The client-side script method to be called when the element is double-clicked
oninitThe client-side script method to be called when the Google Map object is initiated
onkeydown DHTML: The client-side script method to be called when a key is pressed down over the element
onkeypress DHTML: The client-side script method to be called when a key is pressed over the element and released
onkeyup DHTML: The client-side script method to be called when a key is released
onmousedown DHTML: The client-side script method to be called when a mouse button is pressed down over the element
onmousemove DHTML: The client-side script method to be called when a pointer is moved within the element
onmouseout DHTML: The client-side script method to be called when a pointer is moved away from the element
onmouseover DHTML: The client-side script method to be called when a pointer is moved onto the element
onmouseup DHTML: The client-side script method to be called when a mouse button is released
rendered JSF: If "false", this component is not rendered
showGLargeMapControlShows the GLarge control. Default value is "true".
showGMapTypeControlShows the Type switch control. Default value is "true".
showGScaleControlIt shows the scale control. Default value is "true".
styleHTML: CSS style rules to be applied to the component
styleClass JSF: Assigns one or more CSS class names to the component. Corresponds to the HTML "class" attribute.
warningMessageThe warning message that appears if a browser is not compatible with Google Map. Default value is "Your browser does not support Google Maps".
zoomInitial zoom level as a number between 1 and 18. Default value is "17".

Table 6.577. Component identification parameters

NameValue
component-typeorg.richfaces.Gmap
component-classorg.richfaces.component.html.HtmlGmap
component-familyorg.richfaces.Gmap
renderer-typeorg.richfaces.GmapRenderer
tag-classorg.richfaces.taglib.GmapTag

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

Example:


...
<rich:gmap gmapKey="..."/>
...

Example:

import org.richfaces.component.html.HtmlGmap;

...
HtmlGmap myMap = new HtmlGmap();
...

To use Google Map in your application, generate a key on Google Map official resource . One key could be used for one directory on the server.

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

  • "mapType" specifies a type of a rendered map (G_NORMAL_MAP, G_SATELLITE_MAP (DEFAULT), G_HYBRID_MAP)

For example, the city of Paris is shown after rendering with the following initial settings: lat = "48.44" , lng = "2.24" and zoom = "5" .


It's also possible to set accessible controls on the map with the help of the attributes:

  • "showGMapTypeControl" determines whether the controls for a map type definition are switched on

  • "showGScaleControl" determines whether the controls for scaling are switched on

  • "showGLargeMapControl" determines whether the control for map scale rendering is rendered


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 "gmapVar" attribute and then call the object directly with API Google Map .

For example, to approximate a map for gmapVar = "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

Google Map 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>
...

<rich:gmap> component isn't tied to skin parameters, as there is no additional elements on it, except the ones provided with Google Map .


In order to redefine styles for all <rich:gmap> components on a page using CSS, it's enough to create classes with the same names (possible classes could be found in the tables above ) and define necessary properties in them.

Example:


...
.rich-gmap{
    
font-style:italic;
}
...

This is a result:


In the example the font style for buttons was changed.

Also it's possible to change styles of particular <rich:gmap> component. In this case you should create own style classes and use them in corresponding <rich:gmap> styleClass attributes. An example is placed below:

Example:


...
.myClass{
    
font-weight:bold;
}
...

The "styleClass" attribute for <rich:gmap> is defined as it's shown in the example below:

Example:


<rich:gmap ... styleClass="myClass"/>

This is a result:


As it could be seen on the picture above, the font weight for buttons was changed.

On the component Live Demo page you can see the example of <rich:gmap> usage and sources for the given example.