gpt4 book ai didi

javascript - 我的复选框不显示要素图层

转载 作者:行者123 更新时间:2023-11-30 15:22:04 26 4
gpt4 key购买 nike

这是我的代码

else if(which == "abc"){  
var d = (id).toString();
d = d.replace("abc", "");
query.where = "Name='" + d + "'";
console.info(query.where);
query.returnGeometry = true;
layerC.selectFeatures(query, FeatureLayer.SELECTION_NEW, function (features) {
thePoly = features[0].geometry;
theExtent = thePoly.getExtent().expand(1); //Zoom out slightly from the polygon's extent
map.setExtent(theExtent);
});

}
var text;
var R = document.getElementById('abc').value;
var rLyrToggle = dom.byId("rLyr");

switch(Cpt) {
case "room1":
on(rLyrToggle, "change", function() {
building layer.visible = rLyrToggle.checked;

});
break;

default:
text = "No room";
}

我的复选框在检查图层添加到 map 时不显示图层,但我禁用了它的可见性,我希望当组合框选择的值等于情况 1 时,当用户选中该框时该功能可见

最佳答案

好吧,要从 GIS 图层中找到所有值(如评论中所述),我建议使用 queryTask 而不是 esriRequest-

下面是工作代码-

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Query State Info without Map</title>

<script src="https://js.arcgis.com/3.20/"></script>
<script>
require([
"dojo/dom", "dojo/on",
"esri/tasks/query", "esri/tasks/QueryTask", "dojo/domReady!"
], function (dom, on, Query, QueryTask) {

var queryTask = new QueryTask("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5");

var query = new Query();
query.returnGeometry = false;
query.outFields = [
"SQMI", "STATE_NAME", "STATE_FIPS", "SUB_REGION", "STATE_ABBR",
"POP2000", "POP2007", "POP00_SQMI", "POP07_SQMI", "HOUSEHOLDS",
"MALES", "FEMALES", "WHITE", "BLACK", "AMERI_ES", "ASIAN", "OTHER",
"HISPANIC", "AGE_UNDER5", "AGE_5_17", "AGE_18_21", "AGE_22_29",
"AGE_30_39", "AGE_40_49", "AGE_50_64", "AGE_65_UP"
];

on(dom.byId("execute"), "click", execute);
on(dom.byId("findAll"), "click", findAll);

function execute () {
query.where = "";
query.text = dom.byId("stateName").value;
queryTask.execute(query, showResults);
}

function findAll () {
query.where = "1=1";
queryTask.execute(query, showResults);
}

function showResults (results) {
var resultItems = [];
var resultCount = results.features.length;
for (var i = 0; i < resultCount; i++) {
var featureAttributes = results.features[i].attributes;
for (var attr in featureAttributes) {
resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>");
}
resultItems.push("<br>");
}
dom.byId("info").innerHTML = resultItems.join("");
}
});
</script>
</head>

<body>
US state name :
<input type="text" id="stateName" value="California">
<input id="execute" type="button" value="Get Details">
OR
<input id="findAll" type="button" value="Find All">
<br />
<br />
<div id="info" style="padding:5px; margin:5px; background-color:#eee;">
</div>
</body>
</html>

希望这对你有帮助:)

关于javascript - 我的复选框不显示要素图层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43575244/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com