Ctrl + Click Modifier for Picking

1. A concise explanation of the problem you’re experiencing.

I would like to modify the picking to allow multiple picks to show up. I would like to do this with the “Ctrl” + click modifier.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

Here is my attempt at maintaining a “flag.” Unfortunately, this only works for “Command” on Mac and won’t work for “Ctrl” + click because it somehow prevents the default Cesium picking from functioning (i’m guessing Cesium’s picking is bound to LEFT_CLICK and not LEFT_CLICK with the Control modifier.

App.prototype.keydown = function(evt) {
    // Window context
    if (!evt) evt = event;
    if (evt.keyCode === 224 || evt.keyCode === 17 || (evt.keyCode === 91 || evt.keyCode === 93)) {
        this.app.cmdEngaged = true;
    }
}

App.prototype.keyup = function(evt) {
    // Window context
    if (!evt) evt = event;
    if (evt.keyCode === 224 || evt.keyCode === 17 || (evt.keyCode === 91 || evt.keyCode === 93)) {
        if(this.app.cmdEngaged) {
            this.app.cmdEngaged = false;
        }
    }
}

``

This is the “getFeatureInfo” callback.

if (that.app.currentPicks.length > 0 && !that.app.cmdEngaged) {

that.app.deletePicks();

}

that.app.currentPicks.push(that.app.viewer.entities.add({

position : Cesium.Cartesian3.fromDegrees(json.lon, json.lat),

label : {

show : true,

outlineWidth: 4,

font : ‘14pt Lucida Console’,

style : Cesium.LabelStyle.FILL_AND_OUTLINE,

text : (value.toString().length <= 5 ? value : parseInt(value).toFixed(1))

}

}));

``

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

Showing multiple labels on the map like below.

4. The Cesium version you’re using, your operating system and browser.

Trunk/master.

I appreciate any tips or recommendations which might get me on the right track to getting a platform-agnostic approach built. I’m on Mac but the majority of my users are on Windows and by using the “Command” key code, only the “Windows” key works for this. “Ctrl” seems like the best key for both platforms.

Hi Ryan,

When you set the function for you the mouse event with ScreenSpaceEventHandler.setInputAction, you can pass a modifier key as the last argument to the function. If you pass the ctrl key there, (and also have a fallback for Mac), you should get the behvior you want on Windows. Here’s a quick example.

Thanks,

Gabby

Gabby,

Thanks so much! No idea how I missed that.

  • Ryan