GEOLYTIX / xyz

An open source javascript framework for spatial data and application interfaces.
MIT License
88 stars 26 forks source link

Ability to hide the `zoomToExtent` button on a zoom-restricted layer #1718

Open simon-leech opened 4 days ago

simon-leech commented 4 days ago

Description

Currently we always add the zoomBtn if the layer is zoom restricted. However, we should allow configuration to turn this off if the functionality is not required / contextually appropriate.

 // Create a div for the magnifying glass icon
  layer.zoomBtn = layer.tables
    && mapp.utils.html.node`<button 
      data-id="zoom-to"
      title=${mapp.dictionary.zoom_to}
      class="mask-icon search"
      onclick=${() => zoomToRange(layer)}>`

I propose we instead do this, by making it an OR assignment we can make it false to hide it. e.g.

"zoomBtn": false
 // Create a div for the magnifying glass icon
  layer.zoomBtn ||= layer.tables
    && mapp.utils.html.node`<button 
      data-id="zoom-to"
      title=${mapp.dictionary.zoom_to}
      class="mask-icon search"
      onclick=${() => zoomToRange(layer)}>`

(Asana Ticket)

Type of Issue

Please delete options that are not relevant, and select all options that apply.

dbauszus-glx commented 1 day ago

This shouldn't be shown by default and not shown with the false flag which is counter intuitive to mapp json.

The default should be to not show the button and show if configured.

This also opens a can of worms in regards to other elements. If there is an option for the zoomButton, should the zoomToExtentBtn be optional as well.

Should all of these flags be add to the layer JSON or perhaps should there be a config object.

layer.view === null, no view is created. Otherwise view will be the view element. We cannot change this.

dbauszus-glx commented 1 day ago

The only option is see to not break the current behaviour without spamming more and more flags into the layer json is by creating a default object layer.viewConfig = {zoomBtn, zoomToExtentBtn, panelOrder} etc. And you can provide viewConfig taking away the options to change the behaviour.

dbauszus-glx commented 1 day ago

All this should happen in a viewConfig method in the module to reduce the complixity of the view method exported from the module.