gpt4 book ai didi

使用 ArcGIS 的 Javascript : InfoWindow not showing values from field

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

我在另一个显示世界所有国家/地区的要素图层之上有一个包含特定国家/地区的要素图层。

如果您单击这些特定国家/地区,会弹出一个信息窗口。信息窗口应显示国家名称。但事实并非如此。

popup content missing

代码如下。有什么问题吗?

<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>Feature Layer Only Map</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.24/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
</style>
<script src="https://js.arcgis.com/3.24/"></script>
<script>
require([
"dojo/dom-construct",
"esri/map",
"esri/InfoTemplate",
"esri/layers/FeatureLayer",
"esri/geometry/Extent",
"dojo/domReady!"
], function(
domConstruct,
Map,
InfoTemplate,
FeatureLayer,
Extent

) {
var bounds = new Extent({
"xmin":-20037509,
"ymin":-8283276,
"xmax":20037509,
"ymax":17929239,
"spatialReference":{"wkid":102100}
});

var map = new Map("map", {
extent: bounds
});

var url = "https://services8.arcgis.com/qruYQAspohLtOguC/ArcGIS/rest/services/englishspeakingcountries/FeatureServer/0";

var template = new InfoTemplate("Country", "${ADMIN}");

var fl = new FeatureLayer(url, {
id: "englishspeakingcountries_0",
infoTemplate: template
});

map.addLayer(fl);

var url_2 = "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Countries/FeatureServer/0"

var fl2 = new FeatureLayer(url_2);
map.addLayer(fl2, 0);
}
);
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>

最佳答案

使用 Chrome 开发人员工具中的“网络”选项卡,我发现对要素服务的查询仅返回每个要素的 ObjectId 字段和几何图形。使用 outFields 属性来解决这个问题:

var fl = new FeatureLayer(url, {
id: "englishspeakingcountries_0",
outFields: "*",
infoTemplate: template
});

Australia popup

关于使用 ArcGIS 的 Javascript : InfoWindow not showing values from field,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50855940/

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