[geojquery] To plug in or not to plug in?
Oliver Tonnhofer
olt at bogosoft.com
Sat Mar 13 13:06:56 EST 2010
Hi everyone,
I was playing with the jQuery plugin idea and I am not really sure if a plugin is the right way for doing this.
All existing jQuery plugins are - more or less - just playing with DOM objects. Hide that, fade this in, add this event, etc. But we want to work with another library, we don't need access to the DOM elements where we added our maps, we need access to the actual map object (OpenLayer or our own geojquery map objects).
I don't see how this can be implemented in an elegant way when we just want to write a plugin.
Let me give you an example with some code I have[1]:
$('#map').map({
size: [400, 400],
zoom: 7,
center: [8.19884, 53.1495],
layers: [$.map.tms({host:"http://osm.omniscale.net/proxy/tiles/", layer:"osm_EPSG900913"})]
});
Pretty simple. I just created a map inside the #map element. But how do I interact with the map? $('#map') gives me a jQuery object where I can manipulate all attributes from the DOM object, but not the actual map. We can add the OpenLayers map or some geojQuery object as .data() to the element, but $('#map').data('map').center(lonlat) is rather quirky.
One solution would be to add another jQuery method for everything we intend to do with our map.
$('#map').center(lonlat);
$('#map').add_layer(...);
That would work, but it would also pollute the $-namespace. PHP developers might like that but I'm strongly against that. ;)
Maybe I'm missing something, please enlighten me :)
[1] http://bitbucket.org/olt/geojquery-playground/src/
Regards,
Oliver
--
Oliver Tonnhofer <tonnhofer at omniscale.de>
Omniscale - Dominik Helle, Oliver Tonnhofer GbR
Nadorster Str. 60, 26123 Oldenburg
Tel: +49(0)441/9392774-2 (Fax: 9)
More information about the Mapquery
mailing list