非常感谢,斯特凡!但我尝试了第二种“替代方案”,但没有奏效。这是功能:
function filterData() {
var searchString = document.getElementById('search-string').value.replace(/'/g, "\\'");
var filter = document.getElementById('filter').value.replace(/'/g, "\\'");
layer.setOptions({
query: {
select: "'geometry'",
from: '4756019'
where: "'" + filter + "' = '" + searchString + "'"
}
});
}