JasperReports Ultimate Guide - Sample Reference - Schema Reference - Configuration Reference - API (Javadoc)

JasperReports - Map Component Sample (version 4.6.0)


Illustrates the usage of the map component element.

Download All Sample Source Files
Browse Sample Source Files on SVN


Main Features in This Sample

Using the Built-in Map Component


top

Using the Built-in Map ComponentDocumented by Sanda Zaharia


Description / Goal
How to render maps using the built-in map component.

Since
4.1.1


Map Component Overview

The JR built-in map component is based on the public Google Maps APIs. It exposes some of the main characteristics necessary to generate the most common maps, but feature upgrades for this component are planned for future development. The current map component description is found in the components.xsd schema:
<element name="map" substitutionGroup="jr:component">
  <complexType>
    <complexContent>
      <extension base="jr:componentType">
        <sequence>
          <element name="latitudeExpression">
            <complexType mixed="true"/>
          </element>
          <element name="longitudeExpression">
            <complexType mixed="true"/>
          </element>
          <element name="zoomExpression" minOccurs="0" maxOccurs="1">
            <complexType mixed="true"/>
          </element>
        </sequence>
        <attribute name="evaluationTime" type="jr:basicEvaluationTime" use="optional" default="Now"/>
        <attribute name="evaluationGroup" type="string" use="optional"/>
      </extension>
    </complexContent>
  </complexType>
</element>
The Latitude Expression

The <latitudeExpression/> represents the latitude coordinate of the main area, necessary to locate it on the Earth surface. Allowed values are floating point numbers representing degrees from -90° to 90°. The default value is 0.

The Longitude Expression

The <longitudeExpression/> represents the longitude coordinate of the main area, necessary to locate it on the Earth surface. Allowed values are floating point numbers representing degrees from -90° to 90°. The default value is 0.

The Zoom Expression

The <zoomExpression/> represents the initial map zoom level. The expression allows integer values and defaults to 0.

Map Component Example

One can see an example of map component usage in the JRXML sample:
<componentElement>
  <reportElement x="0" y="0" width="515" height="377"/>
  <c:map xmlns:c="http://jasperreports.sourceforge.net/jasperreports/components" 
    xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components 
    http://jasperreports.sourceforge.net/xsd/components.xsd">
    <c:latitudeExpression><![CDATA[$P{latitude}]] ></c:latitudeExpression>
    <c:longitudeExpression><![CDATA[$P{longitude}]] ></c:longitudeExpression>
    <c:zoomExpression><![CDATA[$P{zoom}]] ></c:zoomExpression>
  </c:map>
</componentElement>
Running the Sample

Running the sample requires the Apache Ant library. Make sure that ant is already installed on your system (version 1.5 or later).
In a command prompt/terminal window set the current folder to demo/samples/map within the JasperReports source project and run the > ant test view command.
It will generate all supported document types containing the sample report in the demo/samples/map/build/reports directory.
Then the report will open in the JasperReports internal viewer.



© 2001- Jaspersoft Corporation www.jaspersoft.com