If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Report Studio - Active Report and Google Maps

Started by HigherEdCognosGuru, 16 Mar 2017 11:33:14 AM

Previous topic - Next topic

HigherEdCognosGuru

I have created an active report that has multiple html items. The purpose of this report is to show address for multiple records and when certain records are selected it will show the map markers on the google map. When I run the report as a regular Report Studio Report, it generates as expected. When I run the report as an Active Report, I receive no errors but no data generates. My code is as follows. I would appreciate any thoughts on working through this issue.


Here is the outline of what my report includes:


Above List Report Section
HTML Item 1 (Source Type-Text):

<div id = "two" style="display: block;" >
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map" style="width: 1100px; height: 500px"></div>   
<script type="text/javascript">
var latlng = new google.maps.LatLng(38.8951, -77.0367);
var options = { center : new google.maps.LatLng(38.9047,-77.0164), zoom : 3, mapTypeId : google.maps.MapTypeId.ROADMAP};
var map = new google.maps.Map(document.getElementById('map'), options);
var geocoder = new google.maps.Geocoder();
var marker= new google.maps.Marker(null);
var directionsService = new google.maps.DirectionsService;
var directionsDisplay = new google.maps.DirectionsRenderer;
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById('panel'));
function calcRoute() {
var start = document.getElementById("start").value;
var end = document.getElementById("end").value;
var request = {
origin: start,
destination: end,
travelMode: google.maps.DirectionsTravelMode.DRIVING};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);}});}
google.maps.event.addListenerOnce(map, 'idle', function() {
google.maps.event.trigger(map, 'resize');
map.setCenter(center);
var center = new google.maps.LatLng(38.8951, -77.0367);});
/*
function initialize() {
var mapProp = {
center:new google.maps.LatLng(38.9047,77.0164),
zoom:5,
mapTypeId:google.maps.MapTypeId.ROADMAP}; 
var map=new google.maps.Map(document.getElementById("map"),mapProp);
var geocoder = new google.maps.Geocoder();
var marker= new google.maps.Marker(null);}
google.maps.event.addDomListener(window, 'load', initialize);
*/
// Adding Markers
function AddMarker(address, name, code,type){
geocoder.geocode( {'address' : address}, function(results, status)
{if (status == google.maps.GeocoderStatus.OK){
map.setCenter(results[0].geometry.location);
map.setZoom(4);
if (type == 'Preferred') {if (code== 'SU') {var marker = new google.maps.Marker( {map : map, icon: 'http://maps.google.com/mapfiles/ms/micons/red-dot.png'; , position : results[0].geometry.location });}
else if (code== 'ID') {var marker = new google.maps.Marker( {map : map, icon: 'http://maps.google.com/mapfiles/ms/micons/blue-dot.png'; , position : results[0].geometry.location });}
else  {var marker = new google.maps.Marker( {map : map, icon: 'http://maps.google.com/mapfiles/ms/icons/green-dot.png'; , position : results[0].geometry.location });}}
else  {if (code== 'SU') { var marker = new google.maps.Marker( {map : map, icon: 'http://maps.google.com/mapfiles/ms/micons/red.png'; , position : results[0].geometry.location });}
else if (code== 'ID' ) { var marker = new google.maps.Marker( {map : map, icon: 'http://maps.google.com/mapfiles/ms/micons/blue.png'; , position : results[0].geometry.location });}
else  {var marker = new google.maps.Marker( {map : map, icon: 'http://maps.google.com/mapfiles/ms/icons/green.png'; , position : results[0].geometry.location });}}
var infowindow; if (!infowindow) {infowindow = new google.maps.InfoWindow();} infowindow.setContent(name); google.maps.event.addListener(marker, 'click', function() {infowindow.open(map,marker);});}});}
google.maps.event.addDomListener(window, 'load', Addmarker);
</script>
</div>
<div id="one" style="height:500px;width:1100px;border:1px solid #ccc;font:16px/26px Arial, Garamond, Serif;overflow:auto;">

List Report Section

Record Name Column
Address: This is an HTML item and it is coded as follows:
           HTML Item 1 (Source Type-Text): <a href="#" onClick="AddMarker('
           HTML Item 2 (Source Type-Report Expression): STREET ADDRESS DATA ITEM
           HTML Item 3 (Source Type-Text): ','
           HTML Item 4 (Source Type-Report Expression): Record Name
           HTML Item 5 (Source Type-Text): ')">
           HTML Item 6 (Source Type-Text): </a>
Show on Map Column Header HTML Item (Source Type-Text):
            <script type="text/javascript">
            var checkflag = "false";
            function check(field) {
            if (checkflag == "false") {
            for (i = 0; i < field.length; i++) {
           (function(i){
           window.setTimeout(function(){
           field.click();}, i * 200);}(i));}
           checkflag = "true";
           return "Uncheck All";} else {for (i = 0; i < field.length; i++) {field.click();}
           checkflag = "false";return "Check All";}}
          </script>
          <form name=myform action="" method=post>
          <input type=button value="Check All" onClick="this.value=check(this.form.list)">

Show on Map Data Column:
        HTML Item 1 (Source Type-Text): <input type="checkbox" name="list" onclick="AddMarker('
        HTML Item 2 (Source Type-Report Expression): LOCATION DATA ITEM - IF ( [Business Address] is null ) THEN    ( [Home Address] ) ELSE      ([Business Address])
        HTML Item 3 (Source Type-Text):','
        HTML Item 4 (Source Type-Report Expression):'Name:'+ [Query1].[Record Name]+'Phone Number: '+[Query1].[Phone]+'- Preferred Email: '+[Query1].[Email]+'Type:' + [Query1].[Type]+'-Address Type:'+ [Query1].[Map Address Type]
        HTML Item 5 (Source Type-Text): ','
        HTML Item 6 (Source Type-Report Expression): [Query1].[Type]
        HTML Item 7 (Source Type-Text): ','
        HTML Item 8 (Source Type-Report Expression): [Query1].[Map Address Type]
        HTML Item 9 (Source Type-Text): ')">

Below List Report Section
</div>











AnalyticsWithJay

Could you turn on the Web Developer Tools (f12), go to Console, and monitor what happens? I expect you see some sort of JS error?

I've experienced similar issues in the past when writing my own code in Active Reports.

CognosPaul

Unless something has changed, active reports implicitly ignore script tags. Bob Reddert wrote an awesome workaround here: https://bobsbiblog.wordpress.com/2014/08/25/creating-javascript-functions-in-active-reports/