Use
Google Map into Cognos Report
-
Launch Report Studio. When prompted, select the Go Sales(query) package and a new list report template.
-
Expand the Sales (query) namespace and drag Country, City etc.
-
From the Insertable Objects tab, drag 4 HTML items into the City data item (unlock cell first) and 1 HTML where you want to show Map.
-
Open HTML items and insert the mentioned code.
-
HTML1: <div onClick="AddMarker('
-
HTML2: Change the Source type to “Report Expression” and drag City from query.
-
HTML3: ')">
-
HTML4: </div>
-
Click Ok.
<script
type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false"></script>
<div id="map"
style="width: 700px; height: 400px"></div>
<script
type="text/javascript">
var latlng = new
google.maps.LatLng(40.756, -73.986);
var options = {
center : latlng,
zoom : 1,
mapTypeId :
google.maps.MapTypeId.ROADMAP
};
// Creating the map
var map = new
google.maps.Map(document.getElementById('map'), options);
var geocoder = new
google.maps.Geocoder();
var marker= new
google.maps.Marker(null);
function
AddMarker(address)
{
geocoder.geocode(
{'address' : address}, function(results, status)
{
if (status ==
google.maps.GeocoderStatus.OK)
{
//map.setCenter(results[0].geometry.location);
var marker = new
google.maps.Marker( {map : map,position :
results[0].geometry.location });
var infowindow;
if (!infowindow)
{
infowindow =
new google.maps.InfoWindow();
}
infowindow.setContent(address);
google.maps.event.addListener(marker, 'click', function()
{
infowindow.open(map,marker);
});
}
});
}
</script>
-
Run the report, it will generate the output like below.
-
Click on any City to get marker.