mapbox/wax — Issue #160: Use TileJSON data outside of tooltip
Author: JasonSanford
Created: 2012-02-01 17:02:26+00:00
State: open

I'm guessing I'm missing something that's dead simple here, but I need a way to handle the data for the current mouse position much like the tooltip does. But I don't really want any kind of tooltip on the map. I'll be parsing the data myself and displaying map vectors and attribute information elsewhere on the page.

So, what I came up with was to pass an options object when creating a new `wax.leaf.interaction` object.

wax.tilejson('http://api.tiles.mapbox.com/v2/jcsanford.population.jsonp', function(tilejson) {
map = new L.Map('map')
.addLayer(new L.TileLayer("http://{s}.tiles.mapbox.com/v3/mapbox.mapbox-light/{z}/{x}/{y}.png", {
subdomains: ["a", "b", "c", "d"],
maxZoom: 10,
attribution: 'Tiles Courtesy of MapBox. Map data (c) OpenStreetMap contributors, CC-BY-SA.'
}))
.addLayer(new wax.leaf.connector(tilejson))
.setView(new L.LatLng(39.0, -97.6), 4);

wax.leaf.interaction(map, tilejson, {
callbacks: new not_really_a_tooltip()
});

});

My next guess was that my `not_really_a_tooltip` function should implement `out` and `over` methods.

Basically what I want to happen is to parse the data that would typically be passed to a tooltip. In my case it's some GeoJSON that I can draw map vectors with and a few attributes to throw in some divs. So here's what I came up with:

function not_really_a_tooltip() {
return {
out: function() {
// remove previous map vectors
// clear the divs containing attribute information about the hovered feature
},
over: function(a) {
// JSON.parse the content
// Draw a vector on the map using some part of this parsed JSON that contains geometry for this feature
// Update some div on the page with some attribute info about this feature
}
};
}

This implementation can be found [here](http://geojason.info/demos/leaflet-wax/).

Did I overly complicate this process? Is there a simpler way to do this?