[MapQuery] MapQuery API Proposal

Volker Mische volker.mische at gmail.com
Fri Jan 14 13:45:11 EST 2011


Hi Drew,

we discussed the API quite a lot. To understand the current one, you 
have to understand the idea behind that all. MapQuery is basically two 
parts, MapQuery Core and MapQuery UI. MapQuery UI are the widgets, like 
the layer control or the popup control I'm working on. Those widgets use 
the MapQuery Core. The goal is, that people start to use the widgets and 
are happy with them as they are, they don't need to care about the 
internals (and also not about MapQuery Core).

Therefore .geoMap() (which should relaly be named .mapQuery()) behaves 
like a normal jQuery plugin, and is therefore chainable. If you need 
some internal functionality (which you shouldn't care about as an end 
user), you can easily have access via data('geoMap') (which also should 
be data('mapQuery')).

You might argue that you need .data() for adding new layers. Well, I 
expect that most people pass in all layers they need at the beginning in 
the mapQuery() constructor. Later they add new layers probably through 
some interface, which would again be coded as a widget.

I hope this mail makes it a bit clearer, why this API is like that. 
Though I'm happy to keep discussing and changing it for the best.

Cheers,
   Volker

On 14.01.2011 18:51, Drew Wells wrote:
> MapQuery currently suffers from a little complexity, seen in the
> following api.
> var map = $('#map').geoMap();
> var mapData = map.data('geoMap');
>
> I merged some code that eliminated this by having $("#map").geoMap()
> return the map object instead of the jQuery collection.  This may
> be counterintuitive to others that are normally used to chaining method
> calls in jQuery.
>
> I propose the following solution
>
> $.geoMap([jQuery selector], [options]); //return reference to Object
> containing all all relevant methods
>
> The following type of usage would be available:
> var map = $.geoMap("#map", {
>    layers: [
>                { url: 'http://wms',
>                  type: 'wms',
>                  layers: [states,countries] } ],
>    transparent: true //apply to all layers,
>    ...
>    Other options
>    ...
> });
>
> The then have the option of doing two things, either using
> $.geoMap("#map") to add new controls and/or layers OR $.geoMap returns
> an object which has these methods available.
>
> $.geoMap("#map", {transparent: false }); is the same as map.transparent(
> false )
>
> Ideas for this usage are based on past experiences with $.flot
> http://people.iola.dk/olau/flot/API.txt
>
> -Drew
>
>
>
> _______________________________________________
> MapQuery mailing list
> MapQuery at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapquery



More information about the MapQuery mailing list