Adding a map to Webdrawer

My out-of-the-box webdrawer interface lacks a map for the results!  Here's what it looks like right now....


Let's fix it!

If I open the results list partial class file in the "/Views/Shared" directory, I can partition the page into two columns.

<table id="container" margin="5">
            <td width="50%"><span style="margin-left:10px">Results List</span></td>
            <td width="50%">Results Map</td>
    <td id="listColumn">
            <!-- Search Results go here -->
    <td id="mapColumn"><div id="mapDiv"></div></td>

Next we import the google maps API

<script type="text/javascript" src="">

But I also need to add some code that results in the map being loaded...

		<script type="text/javascript">
			var map;
			var markers = [];
			var mapmarkers = [];
			function initialize() {
				var mapOptions = {
					center: new google.maps.LatLng(27.897349,-82.155762),
					zoom: 7,
					disableDefaultUI: true,
					zoomControl: true,
					panControl: true,
					mapTypeControl: true,
					scaleControl: true,
					streetViewControl: true,
					rotateControl: true,
					overviewMapControl: true
				map = new google.maps.Map(document.getElementById("mapDiv"), mapOptions);
            google.maps.event.addDomListener(window, "load", initialize);

This gives me my desired user interface!


Next I need to have Webdrawer "addMarker" for each record in the results set.  I decided to do this at the very bottom of the results list file, but only if there are records.  And then only for those having a GPS location.

if (Model.Results.Count > 0)
	<script type="text/javascript">
	@foreach (TrimObject record in Model.Results)
		var gpsloc = record.GetPropertyOrFieldString("RecordGpsLocation");
		if ( !String.IsNullOrWhiteSpace(gpsloc) )
			@Html.Raw("addMarker('" + record.GetPropertyOrFieldString("RecordNumber"+ "','" + gpsloc + "');");

So now I've got the page calling "addMarker" for each record in the search results.  I need to store each one in memory by pushing it into the array of markers.  I also need to define the addMarkers method called by the initialize function during page load.  In that method I iterate each of the array elements, create a marker on the map, and store that marker reference for later manipulation.

    function addMarker(rnum, ltlg) {
        var marker = { "rnum": rnum, "ltlg": ltlg };
    function addMarkers(map) {
        for (i = 0; i < markers.length; i++) {
            var marker = markers[i];
            if (marker.ltlg.indexOf('POINT('>= 0) {
                var ltlg = marker.ltlg.replace('POINT(''').replace(')''').split(' ');
                var mapmarker = new google.maps.Marker({
                    position: new google.maps.LatLng(ltlg[1], ltlg[0]),
                    map: map,
                    title: marker.rnum

Now if I refresh my results window I can see records plotted on the map.  Success!


Whoops.... it's becoming clear that my data import is messed up.  It's including locations beyond my desired regional boundary.  I should only be importing Florida facilities!  That issue will be tabled for now.

Geolocations via Content Manager

Before I go through the trouble of writing more code, I should take a look at what's available.  Hopefully by reviewing each component I can make a list of features missing.  Then I can decide how best to cobble together my final solution.

Accessing Facilities via the Thick Client

When performing a search it is easy to specify that the results include the GPS location in both the view pane and the list pane.  Making the fields visible lets me peruse the data and verify I like the results.  There's no way for me to leverage that data here without a mapping interface.


I can use the view pane's GPS Location hyperlink to browse to the location via the map connector.


But that's it.  Only potential thing I see here is swapping out the static google map connector for one that embeds an iframe showing results nearby.

Viewing Facilities via Web Client

The out-of-the-box configuration of the Web Client does not support a grid style layout for meta-data in the search results pane.  As you select an individual record in the results, the right-hand view pane exposes a link to the location.  


To modify the value you'd either get to the registration form via the update button...


Or you click the GPS Location option from the Details drop-down button


That's it.  Nothing else to see here! :(

View Facilities via WebDrawer

Webdrawer is a no-thrills interface for the exposure of public records.  Using it implies (at least to me) that you don't care who the user is and you'll just be reading data.  That fits for my scenario, so let's see what's available.


Entering "**" into the quick search box and pressing enter should result in all facility boxes being returned (I have nothing else in the dataset).  The search results page shows my boxes, but nothing useful to mapping.  


Clicking a facility box yields no mapping fields or data either.  I tried expanding and collapsing all of the regions but no dice.


 A quick check of the Webdrawer installation manual and the HPE support site turns up no hits for various relevant keywords. So I visited the ServiceAPI's Property and Field Definition page and see that "RecordGpsLocation" is the property to include in route details.  I add it to both the routes for the search results (WDRecordList) and record details (WDRecordDetails) templates.

Note that this is the webdrawer configuration file of a remote server

Note that this is the webdrawer configuration file of a remote server

Modifying the configuration file should result in an automatic reload of the IIS application.  A refresh of my search results page gives me the result shown.


A refresh of my record details page does not result in seeing the property.  That's because I added it to the route (which funnels the data in the template), but I did not include it in any of the custom property sets used to group items into the accordion views.  Adding the property to the custom record identification property set should solve the issue.


Refreshing the page gave me a quick laugh.  I wish the GPS location was a hyperlink!


I'm sure there's a better way to handle this, but I found it easiest to go into the propertyRow partial template and wrap the property value output in a condition.  If the value starts with "" then replace the output with a valid link.  Otherwise use the normal condition.  Definitely not an ideal solution.


Now a reload of the page gives me a usable link.  


What's missing?

I have no way, out-of-the-box, to mark search results within the extent of one map.  So re-creating my goal is not possible without more code.  That's ok though.  I've got this! :)