Closed (fixed)
Project:
Openlayers
Version:
6.x-2.x-dev
Component:
OpenLayers Behaviors
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Sep 2009 at 00:45 UTC
Updated:
18 Feb 2010 at 16:00 UTC
Example:
Drupal.behaviors.openlayers_behavior_layerswitcher = function(context) {
var data = $(context).data('openlayers');
if (data && data.map.behaviors['openlayers_behavior_layerswitcher']) {
// Add control
This check fails if there is more than one map, because every map will get this attached to it, and if there is no behaviors array at all, this fails.
This needs to be done to pretty much all the behaviors.
Drupal.behaviors.openlayers_behavior_layerswitcher = function(context) {
var data = $(context).data('openlayers');
if (data && OL.isSet(data.map.behaviors) && data.map.behaviors['openlayers_behavior_layerswitcher']) {
// Add control
Comments
Comment #1
tmcw commentedThis looks valid. One thing I'd note about the patch: I'm in favor of removing the isSet function and replacing it with just
variable === undefined
Which is about the same length, character-wise as the function and is much clearer about how it works. I really think that the openlayers.helper.js functions should be completely eliminated, because they either eliminate more idiomatic javascript (like isSet), do things that jQuery does better (like triggerCustom), or do things you could easily do more quickly in the few calls that they have (like getObject).
Comment #2
tmcw commentedThe behaviors array is always set in 2.x, even if it's an empty array, so this patch isn't necessary.