KlausBenndorf / guide4you

A configurable web client for geo-applications. Uses OpenLayers 5. Optimized for mobile devices.
MIT License
15 stars 5 forks source link

Layer selector should have dynamic width #4

Open penpendede opened 8 years ago

penpendede commented 8 years ago

Currently the layer selector has a pre-defined width. If you add a lengthy layer name you may need to modify this length. And not only that: If the layer names are available in English and Chinese you either have a menu that does not properly fit the English text or one that is much too wide for the Chinese text.

penpendede commented 8 years ago

A possible solution would be to at least dynamically choose a fitting size whenever the data available for display in the menu changes (e.g. start, switching language).

It is open to discussion whether to update it whenever the data that is actually shown changes. Imagine that you have quite short category names and lengthy names of individual layers within the categories. You perhaps want to the width of the menu depend on whether the category has been expanded or not.

penpendede commented 8 years ago

It should be possible to set a minimal and a maximal width so that the layer selector neither becomes ridiculously narrow or covers most of the map.

penpendede commented 8 years ago

One issue is finding out the width of a text measured in pixels. For this it may be helpful to look into http://stackoverflow.com/questions/118241/calculate-text-width-with-javascript

penpendede commented 8 years ago

If the text does not fit into the given width it may be a good idea to add a tooltip that shows the full layer name (an approach quite common in other applications).