Dear all,
I thought I'd take another stab at recapitulating the functionality of my Simile Timeline/Google Maps mashup using Exhibit3. Way back when I first developed
The Itinerary of John website, David Huynh very generously pointed me in the right direction to get the Timeline to control the appearance of markers on the map. I've manage to succeed (partially) in doing
the same thing within Exhibit, but I'm not very happy with the solution. First of all GMaps breaks it, as described below, but more importantly, I can't help suspecting that there's a more direct way to associate Timeline Events with GMap Markers in the custom Timeline, or GMap constructors.
In the Exhibit example linked above (drawing its data from a Google Spreadsheet), I've had to use nested `for` loops to compare the LatLng of Events with the LatLng of the map markers in order to find a match. This seems clumsy and inefficient. Is there any way to associate, when it's created, a Map Marker with an Exhibit database Item? This would obviate the need to match them up in the `OnScrollListener` function. I will fork the github Repo and hack on the source if I need to, but I thought I would first ask the assembled wise here if there is some more straightforward way to do this in either my Timeline or Map constructors.
To make my solution even less satisfactory, it appears that GMaps breaks it anyway, and in a way that I've yet to find an explanation for. (Maybe this is some sort of JavaScript artifact?) There appears to be a float rounding error somewhere. After hunting through the code a lot, it appears that the place where an item's LatLng is plotted on the map and a map icon is generated is in map-view.js (line 459):
Exhibit.MapView.prototype._rePlotItems
When this function calls
currentSet.visit(function(itemID)
A new LatLng is created by `GLatLng()` and is added to `locationData` object.
Then, in a function:
var addMarkerAtLocation = function(locationData)
when a new marker is made:
var marker = new GMarker(point, icon);
it takes its data from a `point` generated thus:
var point = new GLatLng(locationData.latlng.lat, locationData.latlng.lng)
When the GLatLng constructor is invoked, for some reason, in half of my locations the latlng float data is rounded so that the coordinates of the marker no longer matches the coordinates for the exhibit item.
This is, therefore not an Exhibit problem, but rather a Google Maps problem, but if anybody has some insight into why this happens, I'd love to hear about it.
Thanks,
Jon