[geojquery] geojuery core design

Volker Mische volker.mische at gmail.com
Mon Mar 15 03:44:23 EDT 2010


Hi,

tonight I hacked a bit on how geojquery core could look like. It's not
as easy as I've thought it would be. Here's my conclusion, the reasoning
follows.

I suggest that we create an jQuery-ish API around OpenLayers. This means
it is not really tightly connected with jQuery's DOM manipulation, but
with jQuery's design ideas about being simple and the chainability (kind
of).

For not polluting the global or jQuery namespace there will be a single
entry point: $.map() (or $.geo(), $.geojquery(), $.whatever()). It will
have a jQuery object as parameter and probably some initial options:
$.map($('#mymap'), {mymapoptions}

Than you can use functions like .wfs(), .layers(), .vector(),
.whateverwecomeupwith() on it. And there will be a jq() method that
returns an jQuery object. This way you can manipulate your map with pure
jQuery after you've created that map, e.g. for resizing.

Now to the reasoning. I know that this sounds ugly. $('#mymap').map()
looks so much nicer. But as I return a new map object, the old jQuery
functions won't be there. In case e.g. the jQuery selector doesn't match
anything, it will just break, as with map() the jQuery chain is broken
(one could return the original jQuery object in such cases, but if any
other geojquery function follows the map() it will break anyway).

We clearly operate on a map, not on DOM anymore, this should also be
visible to the user of geojquery core.

What do you think? Do you have better ideas? I hope I can put up some
code soon. I haven't coded the $.map() stuff yet. I just stopped when I
was hitting the $().map() wall :)

Cheers,
  Volker




More information about the Mapquery mailing list