In this example, we are going to create a Cognos report with Google maps which shows the distance between the two markers and also the route and direction between the two markers.
Steps:
Steps:
- Take the example which we previously did.
- Declare the below variables:
- Add the below line in the LoadMapGadget() function.
- Add the below lines to the GEvent.addListener of ShowAddress()
- Add a row in the table.
- Add a html item in the last row.
- Source Type : Text
- Set the text to the following.
- Save and run the report.
- To find the route and directions, click on any two markers.
var isCreateHeadPoint = true;
var headMarker, tailMarker;
gdirection = new GDirections(map, document.getElementById("directions"));
if (isCreateHeadPoint) {
//add the head marker
headMarker = marker;
isCreateHeadPoint = false;
}
else{
//add the tail marker
tailMarker = marker;
isCreateHeadPoint = true;
// create a path from head to tail
gdirection.load("from:" + headMarker.getPoint().lat()+ ", " +headMarker.getPoint().lng() +" to:" + tailMarker.getPoint().lat() + "," + tailMarker.getPoint().lng(), {preserveViewport:true});
}
<div id="directions" style="width: 275px"></div>
</body>
</html>
Report Page
Report Output