Tuesday, June 28, 2011

Cognos - Google Map Report with Distance Calculation and Direction Tracking

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:
  1. Take the example which we previously did.
  2. Declare the below variables:

  3. var isCreateHeadPoint = true;
    var headMarker, tailMarker;
  4. Add the below line in the LoadMapGadget() function.

  5. gdirection = new GDirections(map, document.getElementById("directions"));
  6. Add the below lines to the GEvent.addListener of ShowAddress()

  7. 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});
    }
  8. Add a row in the table.
  9. Add a html item in the last row.
    • Source Type : Text
    • Set the text to the following.

    • <div id="directions" style="width: 275px"></div>
      </body>
      </html>
  10. Save and run the report.
  11. To find the route and directions, click on any two markers.
Report Page


Report Output

2 comments:

  1. This tool can be used to find the distance calculator between two named points on a map. You can decide which two points to measure and then find out the distance calculator.

    ReplyDelete
  2. Easily this website could very well irrefutably secure a well known being among the most in advertisment users, because of diligent articles or even fundamental ratings. distance calculator UK

    ReplyDelete