Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Drupal-OpenLayers-改变弹出行为_Javascript_Drupal_Drupal 7 - Fatal编程技术网

Javascript Drupal-OpenLayers-改变弹出行为

Javascript Drupal-OpenLayers-改变弹出行为,javascript,drupal,drupal-7,Javascript,Drupal,Drupal 7,我已经直接在位于openlayers/plugins/behaviors的模块中修改了弹出行为js文件:openlayers\u behavior\u popup.js 按照我的预期,它运行良好,但我不想将我自己的修改放在原始模块中,我想将其添加到我现有的模块中,但我不知道如何做到这一点 我希望该站点不要在openlayers/plugins/behaviors中采用这种行为,而是使用我自己模块中的弹出式行为代码 Drupal.openlayers.addBehavior('openlayers

我已经直接在位于openlayers/plugins/behaviors的模块中修改了弹出行为js文件:openlayers\u behavior\u popup.js

按照我的预期,它运行良好,但我不想将我自己的修改放在原始模块中,我想将其添加到我现有的模块中,但我不知道如何做到这一点

我希望该站点不要在openlayers/plugins/behaviors中采用这种行为,而是使用我自己模块中的弹出式行为代码

Drupal.openlayers.addBehavior('openlayers_behavior_popup', function (data, options) {
    // normal
    var popupSelect = new OpenLayers.Control.SelectFeature(layers,
        {
    // my change here!!
        },
        onUnselect: function(feature) {
    // normal
    }
    }
  );
});

如何更改openlayers的行为代码?

我已通过在我的自定义模块中加载修改javascript文件解决了这个问题,如下所示:

function mycustom_openlayers_init() {   
     // you might want to load only at some specific page
     // if you want so, please have a look to function arg() of drupal
     // place condition before loading the js file below

     drupal_add_js ( drupal_get_path ( 'module', 'mycustom_openlayers' ) . '/js/openlayers_behavior_popup.js', array(
                'weight' => '9999',
              ) );  
}
通过指定更大的权重设置,我的javascript将在加载原始openlayers弹出文件后加载,然后它将覆盖原始文件的行为,以取而代之

我不知道这样做是否正确,但对我来说很有效


请让我知道其他人是否可以为我提供一个比上述更好的编程解决方案。

嗨,我也有同样的问题。未找到任何解决方案:我的上述解决方案适用于我当前的问题,即使它不是那么专业,如果它有帮助,您可以尝试。我只是跟着你走。谢谢你的更新。