如何取消选择功能

Kun*_*Kun 1 openlayers-3

我正在做一个maplayer切换功能,但是当我切换图层时,所选的功能不会被取消选择。我可以知道如何取消选择 openlayer 3 中的某个功能吗?

$("#show-field-map").click(function(event) {
    map.removeLayer(subbasinJsonp);
    map.addLayer(fieldJsonp);
    $('#show-subbasin-map').attr("disabled", false);
    $('#show-field-map').attr("disabled", true);
});

$("#show-subbasin-map").click(function(event) {
    map.removeLayer(fieldJsonp);
    map.addLayer(subbasinJsonp);
    $('#show-field-map').attr("disabled", false);
    $('#show-subbasin-map').attr("disabled", true);
});
Run Code Online (Sandbox Code Playgroud)

aho*_*var 5

Select交互具有以下特征集合:

var select = new ol.interation.Select();
var features = selectInteraction.getFeatures();
Run Code Online (Sandbox Code Playgroud)

您可以调用clear()该选择来取消选择所有功能:

features.clear();
Run Code Online (Sandbox Code Playgroud)