Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ArcGIS的Javascript:InfoWindow不显示字段中的值_Javascript_Arcgis_Esri_Arcgis Js Api_Esri Javascript Api - Fatal编程技术网

使用ArcGIS的Javascript:InfoWindow不显示字段中的值

使用ArcGIS的Javascript:InfoWindow不显示字段中的值,javascript,arcgis,esri,arcgis-js-api,esri-javascript-api,Javascript,Arcgis,Esri,Arcgis Js Api,Esri Javascript Api,我有一个功能层,在另一个功能层上面显示了世界上所有国家的具体国家 如果您单击这些特定国家,将弹出一个信息窗口。信息窗口应显示国家的名称。但事实并非如此 代码如下。怎么了 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, max

我有一个功能层,在另一个功能层上面显示了世界上所有国家的具体国家

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

代码如下。怎么了

<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>

仅要素图层地图
html,body,#map{
身高:100%;
宽度:100%;
保证金:0;
填充:0;
}
要求([
“dojo/dom构造”,
“esri/map”,
“esri/InfoTemplate”,
“esri/图层/功能图层”,
“esri/几何体/范围”,
“dojo/domReady!”
],功能(
DOMConstructure,
地图,
信息模板,
特征层,
范围
) {
var界限=新范围({
“xmin”:-20037509,
“ymin”:-8283276,
“xmax”:20037509,
“ymax”:17929239,
“空间参考”:{“wkid”:102100}
});
var map=新映射(“映射”{
范围:界限
});
变量url=”https://services8.arcgis.com/qruYQAspohLtOguC/ArcGIS/rest/services/englishspeakingcountries/FeatureServer/0";
var-template=newinfotemplate(“Country”,“${ADMIN}”);
var fl=新功能层(url{
id:“英语国家0”,
infoTemplate:template
});
map.addLayer(fl);
var url_2=”https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/World_Countries/FeatureServer/0"
var fl2=新的功能层(url_2);
map.addLayer(fl2,0);
}
);

使用Chrome开发者工具中的网络选项卡,我发现对功能服务的查询只返回每个功能的
ObjectId
字段和几何图形。使用
外场
属性修复此问题:

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