[MapQuery] Layer Controller Widget Options and Labeling
Steven Ottens
steven at minst.net
Tue Jun 21 17:59:27 EDT 2011
Hi Justin, all,
Interesting topic
I hoped using templates one would get a level of freedom and flexibility. By replacing/overriding the template one can create a custom look and feel. I've noticed that the template engine is very forgiving on giving it parameters it is not actually using. Also currently the widgets have functions which are only available when certain DOM elements are there, if they're not there, the function fails silently. Since by using templates the HTML code is nicely contained I would assume that it will behave nicely when replaced with something else. TBH I've not tried it and would love an example where such a thing is tried.
In general I'd say a widget has n functions, the template should create DOM elements that make them accessible/trigger them. If the widget template is replaced by another template, this template can provide 0-n functions of the widget by adding the specific DOM elements required by the functions. If you want to provide a new function, you need to somehow extend the widget.
This is one approach where you manage widgets functionality by adding DOM elements to your application through the template.
An alternative approach would be with options on widgets. I think certain widgets do have the need of options, but I'm not sure if everything should be accessible through options. I think it is quite complicated to build your widget with all the options. On the other hand, jQuery UI does provide everything with options. However they are options regarding the actual UI element. Setting an option in the Layer object to change something in the LayerControl widget is not the same. I think it would be nice to make one or more layers non deletable, but that would be a specific widget function, which requires probably both code in the widget and in the core.
As such I'm inclined to say that providing options is the way forward, but as long as options are not an option (pun intended) you should be able to override the template without braking the widget. So feel free to make sure that the few widgets I've written are fully configurable :) We should also investigate if and how template-overriding is supposed to work. It would be nice for a developer/designer to be able to reshuffle the DOM elements of a template to create a new layout without having to actually hack mapquery. If this is possible, we need to refer in our widgets to classes, no elements (like 'li') since a designer might want to put the content in a different type of element.
Steven
On Jun 21, 2011, at 7:45 PM, Justin Penka wrote:
> Something I have been interested in getting opinions on regards the flexibility of the Layer Controller Widget. For instance, I rarely want to give my end users the ability to delete a map layer from the map, especially if there is no way for them to get it back after they delete it. Additionally I often generate my layer labels as separate layers, this gives the user the ability to deactivate labeling that may interfere with the map itself and also allows me the opportunity to set the levels of zoom that I would like the labeling to appear on a dynamic basis.
>
> In the old version I managed to do this by overriding the .template used for drawing the layer controller. I know Volker isn’t a huge fan of this method and it certainly has plenty of drawbacks. For instance I added an additional checkbox next to the visible checkbox to represent the labeling of the layer visibility, and removed the delete button from the custom template. Unfortunately because the template is so heavily linked to the core code anytime an activity occurred, such as moving a layer the widget would revert back to the default template and remove any changes included by my template.
>
> It would appear that overriding the template is perhaps not the best approach. I think it would be good if we could have options associated with each layer in the layer controller to activate or deactivate the various options. (ie delete button, visibility checkbox, or possible layer label checkbox). Open to opinions, ideas and suggestions..
>
> -Justin
>
> _______________________________________________
> MapQuery mailing list
> MapQuery at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapquery
More information about the MapQuery
mailing list