Jump to content
We've recently updated our Privacy Statement, available here ×
  • How to remove controls form the Google Map


    amitsd
    • Features: Maps Version: v6.3 Product: JasperReports® Library

    Problem Description

    Google Map component by default displays controls that allow to choose between report types like terrain, satellite, etc. or Pegman control to start "street view". There is no way in Jaspersoft Reports to control visibility of these controls.


    Solution

    JasperReports library does not provide any API or parameters to configure the visibility of the controls on Google Map. But fortunately, Google Maps API support this through the MapsOptions.

    Till the time TIBCO decides to add this configuration through JasperReports component library, I am managing with a work-around.

    NOTE: This solution is making changes to the jasperreports.jar provided with the JSR deployment. So make sure to keep a backup copy of original jar so that you can revert, if needed. Also, these changes will have to be re-applied when JSR upgrades to later version.

    1. Locate jasperreports.jar in the webapps folder. In Pro version 6.3.0, I found it under /var/lib/tomcat7/webapps/jasperserver-pro/WEB-INF/lib. Now open this jar using tools like 7-zip (no need to extact, we will make changes within the jar).
    2. Open file netsfjasperreportscomponentsmapresourcesrequirejasperreports-map.js and locate the function _showMap. This includes the declartion of 'myOptions' object which contain MapOptions for the Google Map. Add your customization code in this object as follows:
    myOptions = {
        zoom: zoom,
        center: new gg.LatLng(latitude,longitude),
        mapTypeId: gg.MapTypeId[mapType],
        autocloseinfo: true,
        streetViewControl: false, // This is to hide Pegman control
        /* add your customation here as per Google Maps API documentation */
    },

     

    1. Now, open file netsfjasperreportscomponentsmapresourcestemplatesMapElementHtmlTemplate.vm and apply similar change where map object is created.
    var map = new google.maps.Map(document.getElementById('${mapCanvasId}'),{
        zoom: ${zoom},
        center: new google.maps.LatLng(${latitude}, ${longitude}),
        mapTypeId: google.maps.MapTypeId.${mapType},
        autocloseinfo: true,
        streetViewControl: false, // This is to hide Pegman control
       /* add your customation here as per Google Maps API documentation */
    });

     

    1. Save the changes, re-package the .jar archive with updated files and restart the server.

     

    NOTE: This work-around applies to the entire Jaspersoft Server, so all the reports on that server will use the same Google Maps configuration.


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...