簡體   English   中英

ol-ext控制條和控制器中的功能

[英]ol-ext Control Bar and function in the 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) { ..... 

首先檢查MyApp.js中的MyApp.js this.getController() MyApp.js引用MyAppController

您不能像ol.control.Button組件一樣使用ol.control.Button

您應該在MyApp.js范圍中使用this

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM