Jump to content
Changes to the Jaspersoft community edition download ×
  • Experimenting with Japsersoft 5.0.1 product using Markers in Google Map


    tchen
    • Features: Maps, Reports Version: v5.0.1 Product: JasperReports® Library

    To plot markers on a Google Map in a JasperReports report, users need to use a sub data source to provide latitude and longitude coordinates to mark the map. To configure the map marker property in iReport Designer, right click on the map, and select “Edit Markers” to enter marker data source information. Then provide marker settings use expression of $F{latitude}.floatValue() and $F{longitude}.floatValue() to set the coordinates. Marker title and icon property settings can also be added to the map. The following is a sample map configuration in the report template:

    <mp:map xmlns:mp="http://jasperreports.sourceforge.net/jasperreports/components"
            xsi:schemalocation="http://jasperreports.sourceforge.net/jasperreports/components
                                http://jasperreports.sourceforge.net/xsd/components.xsd">
        <mp:latitudeexpression>
            <!--[CDATA[$F{latitude}.floatValue()]]-->
        </mp:latitudeexpression>
        <mp:longitudeexpression>
            <!--[CDATA[$F{longitude}.floatValue()]]-->
        </mp:longitudeexpression>
        <mp:zoomexpression>
            <!--[CDATA[13]]-->
        </mp:zoomexpression>
        <mp:markerdataset>
            <datasetrun subdataset="Markers" uuid="839e1f01-dfc6-418c-9676-188ee34c60e8">
                <datasetparameter name="query">
                    <datasetparameterexpression>
                        <!--[CDATA[$P{query}]]-->
                    </datasetparameterexpression>
                </datasetparameter>
                <connectionexpression>
                    <!--[CDATA[$P{REPORT_CONNECTION}]]-->
                </connectionexpression>
            </datasetrun>
            <mp:marker>
                <mp:markerproperty name="latitude">
                    <valueexpression>
                        <!--[CDATA[$F{latitude}.floatValue()]]-->
                    </valueexpression>
                </mp:markerproperty>
                <mp:markerproperty name="longitude">
                    <valueexpression>
                        <!--[CDATA[$F{longitude}.floatValue()]]-->
                    </valueexpression>
                </mp:markerproperty>
                <mp:markerproperty name="title">
                    <valueexpression>
                        <!--[CDATA[$F{markername}]]-->
                    </valueexpression>
                </mp:markerproperty>
                <mp:markerproperty name="icon">
                    <valueexpression>
                        <!--[CDATA[$F{markericon}]]-->
                    </valueexpression>
                </mp:markerproperty>
            </mp:marker>
        </mp:markerdataset>
    </mp:map>
    

    Users can download the attached “GoogleMapMarkersSampleReport1.zip” and “GoogleMapMarkersSampleReport2.zip” files and import them into JasperReports Server 5.0.1 repository. Under repository Public/Samples/Reports folder, “21. Google Map Report (Markers)” shows a single map with markers in SF area. “21. Google Map with Markers Sample Report” shows three maps created through sub report from main report with dynamic map zooming.

    Notes:

    • The Google map with markers example only works in Jaspersoft 5.0.1 release version. iReport Designer Pro 5.0 packaged with JasperReports Server 5.0.1 release does not support this feature. In order to see the whole effect of Google map markers feature demonstrated in the sample reports, uses need to run the report in JasperReports Server Pro release 5.0.1.
    • Users need to copy the htmlcomponen jar (attached) into WEB-INFlib directory to make the "Sample Report" work.
    • To make the sample reports work in JasperReports Server-pro 5.1, users need to replace the jasperreports-5.1.0.jar under WEB-INFlib directory with the new one (attached below) to fix a bug relating to map markers. Please make sure to restart server to have the fix take effect.
    • It is important to understand that the sample reports shown here is "experimental" - they are merely demonstrating on how to render HTML inside non-HTML formats with Jaspersoft product. HTML component is NOT part of the core JasperReports product and conceptually JasperReports cannot fix this component therefore Jaspersoft does not (plan to) support it. The sample is for experimental and proof of concept purpose only.

    1-map.png.535a9eda155026c4d5025713491c841c.png

    2-map.png.686470171f0e18e40f788f13bd96cc5b.png


    (TTC)

    googlemapmarkerssamplereport1.zip

    googlemapmarkerssamplereport2.zip

    jasperreports-htmlcomponent-4.7.1.jar

    jasperreports-5.1.0.jar


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...