[OpenLayers-Dev] preliminary UTFGrid support in OpenLayers

Matt Perry perrygeo at gmail.com
Thu Feb 16 14:08:46 EST 2012


Hey all - I'm excited to share my implementation of OpenLayers support
for UTFGrids. I wanted to get some feedback before doing a pull
request.

Just a little background: UTFGrids are json "hit grids" used to
provide a high degree of interactivity. For example, you can have
mouseover events that display the attributes of the features *without*
fetching additional data from the server. The best demo of the concept
is probably http://mapbox.com/demo/visiblemap/.

This functionality exists in the wax library and is largely deployed
with ModestMaps. I've ported it to native OpenLayers code to better
integrate with OL event handlers and such. There are three additional
components: a UTFGrid Layer, Control and Tile. It has both ajax and
jsonp loading protocols, tries to keep a clear separation between the
grid layers, the grid controls and callbacks which allows things like
multiple handlers and multiple hit grids per map.

Some example code:
	var world_utfgrid = new OpenLayers.Layer.UTFGrid(
	    'UTFGrid Layer',
	    "http://tiles.example.com/world_utfgrid/${z}/${x}/${y}.json"
	);
	map.addLayer(world_utfgrid);

	var control = new OpenLayers.Control.UTFGrid({
	    'div': 'attrsdiv',
	    'layers': [world_utfgrid],
	    'handlerMode': 'move'
	})
	map.addControl(control);


Some demos:
http://labs.ecotrust.org/utfgrid/events.html
http://labs.ecotrust.org/utfgrid/multi.html

and source:
https://github.com/perrygeo/openlayers/tree/utfgrid

Any thoughts on getting this into 2.12? This is my first substantial
effort in extending OpenLayers so if you have any critiques or
concerns that need to be addressed before a pull request would be
considered, let me know.
-- 
·´¯`·.¸. , . .·´¯`·.. ><((((º>`·.¸¸.·´¯`·.¸.·´¯`·...¸><((((º>
"The best way to predict the future is to invent it."  -- Alan Kay
Matthew T. Perry
http://www.perrygeo.net
http://viedevelo.wordpress.com


More information about the Dev mailing list