javascript - ol-ext 控制栏和Controller中的功能
问题描述
我有一个 extjs 应用程序,我在其中使用 ol-ext 控制栏。控制栏位于文件MyApp.js中,单击属于控制栏的按钮我想调用的函数位于相关控制器MyAppController中。在 MyApp.js 中:
var testFuction = function(){
return this.getController().updateImages;
};
var mainbar = new ol.control.Bar();
var first = new ol.control.Button (
{
html: '1',
//handler: 'updateImages',
//reference: 'locationShowImageButton',
handleClick: testFuction,
});
//Standard Controls
mainbar.addControl (first);
mainbar.setPosition('bottom-right');
this.map.addControl(mainbar);
在 MyAppController 中:
updateImages: function (obj) {
var self = this;
this.getView().cleanImageLayers();
var selectedFloors = ; //it should be the value of the ol.control.Button, so 1
if (this.lookupReference('locationShowImageButton').pressed) {
.....
解决方案
首先检查是否this.getController()
在MyApp.js
参考MyAppController
。
您不能使用
ol.control.Button
like sencha 组件。
你应该this
在你的MyApp.js
范围内使用。
var mainbar = new ol.control.Bar();
var me = this;
var first = new ol.control.Button (
{
html: '1',
handleClick: function () {
me.getController().updateImages();
}
});
//Standard Controls
mainbar.addControl (first);
mainbar.setPosition('bottom-right');
this.map.addControl(mainbar);
推荐阅读
- local-storage - 关于 BlazingPizza Blazor 应用程序使用的本地数据库的问题
- r - 了解 Markdown 和 Knitr 的基础知识
- c++ - 当用户这样说时停止 while / for 循环
- python-3.x - 数据流转换将相同的输入发送到输出
- javascript - 使用 MEAN Web App 链接社交媒体帐户
- oracle - 如何设置变量并在 Oracle PL/SQL 的选择查询中使用它?
- python - 如何解决 IPython Notebook 中大单元格中的双击问题?
- codeigniter - Ion_auth 控制器错误:无法加载请求的文件
- javascript - 当更新可用且设备离线时,如何在 PWA 中显示横幅?
- mongodb - nestjs mongoose 类型“字符串”不可分配给类型“条件”
>