[MapQuery] starting a widget API is wrong

Volker Mische volker.mische at gmail.com
Wed Jun 29 18:37:58 EDT 2011


On 06/29/2011 10:27 PM, Steven Ottens wrote:
> Hey all,
> 
> I'm cleaning up the widgets in my fork and am trying to make them all in the same style. I noticed that Volkers widgets start like this:
>   $('#featureinfo').mqFeatureInfo({
>         map: $('#map'),
>         contents: function(feature) {
>             return '<p>' + feature.data.id + '</p>';
>         }
>     });
> Where mine start like this:
>  $('#overview').mqOverviewMap($('#map'));
> 
> Volkers code does this:
>  var map = this.options.map.data('mapQuery');
> 
> Where I do this:
>         if (this.options.jquery === $().jquery) {
>             map = this.options.data('mapQuery');
>             this.options = {};
>         }
>         else {
>             map = this.options.map.data('mapQuery');
>         }
> 
> According to the API docs ( https://github.com/mapquery/mapquery/wiki/API-for-the-application-developer ) the way to call a widget is this:
> A widget is initialised with $(selector).mqWidget("mapselector",{options}); 
> 
> I don't have a big preference*) on which way to follow, but we have to be consistent. By the looks of it neither of our methods are following the API specs. Since both methods are invalid to the API we can do three things: fix our code to follow API or to fix the API to follow Volker or me (and fix code accordingly). 
> 
> *) I've got the slightest of preferences for the API way: the map should always be passed and options are optional.
> 
> What are your opinions?
> 
> Steven
> 
> ps. since all the widgets for a 0.1 release are in my fork I'm pushing for a first release in July - jay!

Hi Steven,

good discovery. I actually like the API docs way most.

Cheers,
  Volker


More information about the MapQuery mailing list