The layer name (machine name) is displayed in layer switcher, when the layer title (human readable) should be displayed.

Comments

Will White’s picture

Version: 6.x-2.x-dev » 6.x-2.0-alpha3

Changed affected version.

zzolo’s picture

Status: Active » Fixed

Fixed: http://drupal.org/cvs?commit=339820

The value passed to the layer functions was the array index, not the layer title.

tmcw’s picture

Status: Fixed » Needs work

This breaks some functionality: there's a gotcha here, in that the old style layer names were used to reference layers (in the ZoomToLayer behavior, for example), sot his change broke them. But this change is also somewhat necessary, because we want nice things in layer switchers. But 'fixing' zoomtolayer is not enough, because this change prevents us from having unique identifiers for layers. There needs to be some kind of fix here.

zzolo’s picture

Ah, because the name that you give the layer when you create it in OpenLayers is the name to reference it by? Hmmm. Yeah, we definitely need the more-friendly display.

How about this? Can we add the layer name (unique identifier) to the layer object when we create it?

tmcw’s picture

This is likely another regression caused by this change: http://drupal.org/node/749054

zzolo’s picture

Version: 6.x-2.0-alpha3 » 6.x-2.x-dev
Assigned: Unassigned » zzolo

I will work on this tonight. I'd rather get through this issue that revert it.

tmcw’s picture

Probably the best solution is to add an id parameter to the layer init code and then use the map object's getLayersBy method whenever we need to select a layer by this id.

zzolo’s picture

Status: Needs work » Fixed

http://drupal.org/cvs?commit=345038
I have tested this to the best of my ability and appreciate any other eyes on it. Closing related tickets as well.

The addLayers function, now adds a drupalID property to the options array which gets inserted in the actual Layer itself. So this is now the way to reference the layer. You could use a function like this to get the layer, given openlayers is your map object (which btw is kind of confusing)

openlayers.getLayersBy('drupalID', layer_name);

I have also updated each layer handler function to use this change for style maps, and I also change the fir argument in this function to be title since it is a better description on what it is (name is the property that the Layer uses). Example.

Drupal.openlayers.layer.wms = function (title, map, options) {
  var styleMap = Drupal.openlayers.getStyleMap(map, options.drupalID);
  // ....
  var layer = new OpenLayers.Layer.WMS(title, options.url, options.params, options);
}

Updated default base layer code. Though I am curious as why this:

    // Set our default base layer
    for (var layer in openlayers.layers) {
      if (openlayers.layers[layer].drupalID === map.default_layer) {
        openlayers.setBaseLayer(openlayers.layers[layer]);
      }
    }

Couldnt be this. I tried to get it to work but to no avail.

    // Set our default base layer
    openlayers.setBaseLayer(openlayers.getLayersBy('drupalID', map.default_layer));

* Updated views layer handler
* Updated zoomtolayer
* Updated CCK behaviors with IDs, though this should have been working fine before, as there was no need for IDs.

tmcw’s picture

I would assume that getLayersBy always returns an array, and setBaseLayer expects a single layer.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.