File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -159,13 +159,30 @@ Get an array of default items.
159
159
160
160
## Events
161
161
162
- #### Listen and make some changes before context menu opens
162
+ #### If you want to disable this plugin under certain circumstances, listen to ` beforeopen `
163
+
164
+ ``` javascript
165
+ contextmenu .on (' beforeopen' , function (evt ){
166
+ var feature = map .forEachFeatureAtPixel (evt .pixel , function (ft , l ){
167
+ return ft;
168
+ });
169
+
170
+ if (feature) { // open only on features
171
+ contextmenu .disable ();
172
+ } else {
173
+ contextmenu .enable ();
174
+ }
175
+ });
176
+ ```
177
+
178
+ #### Listen and make some changes when context menu opens
163
179
164
180
``` javascript
165
181
contextmenu .on (' open' , function (evt ){
166
182
var feature = map .forEachFeatureAtPixel (evt .pixel , function (ft , l ){
167
183
return ft;
168
184
});
185
+
169
186
if (feature) {
170
187
// add some other items to the menu
171
188
}
You can’t perform that action at this time.
0 commit comments