6.14.3. < Rich:gmap > Available Since 3.0.0

Create new RichFaces Documentation Jira issue

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

JBoss.orgCommunity Documentation

  • Prev
  • Next

6.14.3.  < rich:gmap > available since 3.0.0

expand all  6.14.3.1. Description  6.14.3.2. Key Features  6.14.3.3. Details of Usage  6.14.3.4. Reference Data  6.14.3.5. Relevant Resources Links

6.14.3.1. Description

Component that presents the Google map in the JSF applications.

<rich:gmap> component

Figure 6.179.  <rich:gmap> component

6.14.3.2. Key Features

  • Presents all the Google map functionality

  • Highly customizable via attributes

  • No developers JavaScript writing needed to use on a pages

6.14.3.3. Details of Usage

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" .

<rich:gmap> initial rendering

Figure 6.180.  <rich:gmap> initial rendering

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

<rich:gmap> accessible controls

Figure 6.181.  <rich:gmap> accessible controls

To set the controls as well as to perform other activities (Zoom In/Out etc.) is possible with your JavaScript, i.e. declare a name of a map object in the "gmapVar" attribute and then call the object directly with Google Maps API.

For instance, if you have gmapVar = "map" declared for your component, to zoom in a map you should call map.zoomIn() on an event. See also an example of <rich:gmap> usage on the RichFaces Live Demo.

Tip:

You do not need to use reRender to perform uptades for the <rich:gmap> component. Use the "gmapVar" attribute and Google Maps native API instead as it's described above.

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:viewcontentType="text/html">...</f:view> ...

6.14.3.4. Reference Data

Table of <rich:gmap> attributes.

Table 6.247. 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

Table 6.248.  Classes names that define a component appearance

Class nameDescription
rich-gmap Defines styles for a wrapper <div> element of a component
You can find all necessary information about style classes redefinition in Definition of Custom Style Classes section.

6.14.3.5. Relevant Resources Links

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

  • Prev6.14.2.  <rich:effect> available since ...
  • Top of page
  • Front page
  • Next6.14.4.  < rich:virtualEarth > ...

Từ khóa » Gmap Bản đồ