Friday, August 30, 2013

[OBIEE 10g] Integrating OBIEE And Google Maps And Drilling To Dashboards



 



Integrating OBIEE and Google Maps and Drilling to Dashboards






To integrate Google maps into an OBIEE application the users requested the ability to look at a Map of the US and see concentrations of points on a map. They wanted to see at a national level where incidents they were interested in were located. They also wanted the ability to zoom in and see exactly where each incident occurred. Another solution to meet the requirement is by Integrating OBIEE and Google Maps with the MarkerClusterer API. This is another example of the same clustering map on our system but with more navigation enabled.


Once a user zooms into a level on the map that has single location icons they have the ability to click on the icon and see some basic information about the event represented.
 



 
The user can then decide if more information is needed. By clicking on the text in the popup the user is directed to a new dashboard showing the origin, destination, and location of an incident. The following dashboard has another report that plots three addresses on a Google map, and allows for further navigation to company information or a BI publisher report on the incident details. 





The above shows you what the user can do with map interaction now let’s look at the code as to how it is done. We will start with some basics I mentioned in the last blog. 
  1. First we geocoded our addresses and stored latitudes and longitudes for each data point we wanted to map. If you do not geocode the addresses you really need to work with less points (less than 1000) and the results will take much longer. The code is based on having lat and longs.  
  2. Then we created a query that has the company facility name and internal company number (used for navigation), lat and long, and a piece of data called rank for displaying on the single points in the map. The RSUM(1) is used for displaying if more that 3000 rows could be displayed in the map.

 




Because this drill down is based on the clustering API the code reflects that API. Note it is not necessary to use the clustering API as the basic Google Maps API allows on click events.


The heavy lifting is done in a narrative view using JavaScript, the Google maps API, and the MarkerCluster API


  1. Get a Google Maps API Key from: http://code.google.com/apis/maps/signup.html.  Google maps API uses a key generated based on the IP and name from the calling server, so be sure you are on your web server when obtaining this. Get a key based on your own OBIEE server address.
  2. Create a narrative view and make sure you mark the contains HTML Markup checkbox
  



I will add all the code after we examine the parts of the code dedicated to the pop up box and link to a dashboard. 

function initialize1(lat, long, cnt, ncident_num, incident_dt, incident_sev)


This initializes the values from the query using this from the narrative and basing the values from the order of column in the criteria tab.

initialize1(‘@2′,’@3′,’@4′,’@1′,’@5′,’@7′)

point1 = new GLatLng(lat, long);
marker = createMarker(point1,incident_num,incident_dt,incident_sev);
markers.push(marker);

This code initializes the single data points to display on the map and stores the incident number, date, and severity on the data point to display in the popup.


if (cnt == 1 )
{
var markerCluster = new MarkerClusterer(map1, markers);
}
}
function createMarker(point, popuphtml, date, severity)
{
var marker = new GMarker(point);
GEvent.addListener(marker, “click”, function() {marker.openInfoWindowHtml(“” + “Incident Number: ” + popuphtml +”
” + “Incident Date: ” + date+ “
“);});
return marker;
}



This code runs for each data point to show and displays the point, the popup box, and the on click event of navigating to the incident dashboard. The dashboard link is passing the prompts for the next dashboard. The popuphtml is a variable for incident number from the criteria.



And set the max rows to a number less than 5000.


The subsequent map is a little more straight forward, as it does not have the MapCluster API embedded.







This map has 3 different addresses describing the same event plotted with 3 different icons. 


The Criteria for this map has 3 locations latitude and longitudes

Now for the map create a narrative report and use only 1 row to display






 


No comments:

Post a Comment