【问题标题】:Esri InfoWindow not showing results returnedEsri InfoWindow 未显示返回的结果
【发布时间】:2015-02-11 02:30:41
【问题描述】:

我在尝试使用 ArcGIS 检索数据并将它们显示到 infoWindow 时遇到了一些问题。这是我的javascript:

var map;
require(["esri/map","esri/dijit/Scalebar","esri/layers/FeatureLayer", "esri/dijit/Legend", 
     "dojo/_base/array", "dojo/parser", 
     "dijit/layout/BorderContainer", "dijit/layout/ContentPane", 
     "dijit/layout/AccordionContainer","esri/InfoTemplate","dojo/dom-construct","dojo/domReady!"], 
     function(Map,Scalebar, FeatureLayer, Legend, arrayUtils, parser, InfoTemplate,domConstruct){
    parser.parse();
    map=new Map("map", {
    center:[-56.049, 38.485],
    zoom:3,
    basemap: "topo"});

// Show legend
map.on("layers-add-result", function(evt){
var layerInfo = arrayUtils.map(evt.layers, function(layer, index){
    return {layer:layer.layer, title:layer.layer.name};
});

if(layerInfo.length >0){
    var legendDijit = new Legend({
    map:map,
    layerInfos: layerInfo}, "legendDiv");
    legendDijit.startup();
}
});

var legendFeature = new 
     FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3", { 
     mode: FeatureLayer.MODE_ONDEMAND, 
     outFields:["*"] 
     });

// Show infoWindow 
var content = "<b>State</b>: ${STATE_NAME}";
var infoTemplate = new InfoTemplate("${STATE_NAME}", content);
            featureLayer = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3",
            {
                mode: FeatureLayer.MODE_ONDEMAND,
                infoTemplate: infoTemplate,
                outFields: ["*"]
            });
map.addLayers([featureLayer]);

// Show scalebar
var scalebar = new Scalebar({
    map:map,
    scalebarUnit: "dual",
    attachTo:"bottom-left"});
});

图例和比例尺没有问题。但是,当我单击某个区域时,它确实弹出了一个 infoWindow 但没有任何结果。我想知道为什么它不起作用。

提前致谢。

【问题讨论】:

    标签: javascript arcgis infowindow esri arcgis-js-api


    【解决方案1】:

    您需要的 AMD 模块的顺序必须与您获得的构造函数的顺序相对应。在您的情况下,InfoTemplate 对应于“dijit/layout/BorderContainer”:

      require(["esri/map", "esri/dijit/Scalebar", "esri/layers/FeatureLayer", "esri/dijit/Legend",
             "dojo/_base/array", "dojo/parser",
             "dijit/layout/BorderContainer", "dijit/layout/ContentPane",
             "dijit/layout/AccordionContainer", "esri/InfoTemplate", "dojo/dom-construct", "dojo/domReady!"],
             function (Map, Scalebar, FeatureLayer, Legend, arrayUtils, parser, InfoTemplate, domConstruct) {...
    

    这将起作用:

       require(["esri/map", "esri/dijit/Scalebar", "esri/layers/FeatureLayer", "esri/dijit/Legend",
             "dojo/_base/array", "dojo/parser",
             "dijit/layout/BorderContainer", "dijit/layout/ContentPane",
             "dijit/layout/AccordionContainer", "esri/InfoTemplate", "dojo/dom-construct", "dojo/domReady!"],
             function (Map, Scalebar, FeatureLayer, Legend, arrayUtils, parser, BorderContainer, ContentPane, AccordionContainer,  InfoTemplate, domConstruct) {...
    

    【讨论】:

    猜你喜欢
    • 2013-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多