【问题标题】:How to Add and Display images in Identifier Popup如何在标识符弹出窗口中添加和显示图像
【发布时间】:2016-05-15 00:04:55
【问题描述】:

我有一个标识符,如果我单击特定点,它将显示该点的所有信息。现在的问题是需要为每个点添加图像,如果我单击该点,它将显示信息和图像。目前我正在使用

 map.on("load", mapReady);

        var parcelsURL = "My Server";
        //map.addLayer(new ArcGISDynamicMapServiceLayer(parcelsURL,
        //  { opacity: 20 }));

        function mapReady() {
            map.on("click", executeIdentifyTask);
            //create identify tasks and setup parameters 
            identifyTask = new IdentifyTask(parcelsURL);

            identifyParams = new IdentifyParameters();
            identifyParams.tolerance = 3;
            identifyParams.returnGeometry = true;
            identifyParams.layerIds = [0];
            identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;
            identifyParams.width = map.width;
            identifyParams.height = map.height;
        }

        function executeIdentifyTask(event) {
            identifyParams.geometry = event.mapPoint;
            identifyParams.mapExtent = map.extent;

            var deferred = identifyTask
              .execute(identifyParams)
              .addCallback(function (response) {
                  // response is an array of identify result objects
                  // Let's return an array of features.
                  return arrayUtils.map(response, function (result) {
                      var feature = result.feature;
                      var layerName = result.layerName;

                      feature.attributes.layerName = layerName;
                      if (layerName === 'GridPoint') {
                          var taxParcelTemplate = new InfoTemplate("",
                            "XX: ${XX} <br/> YY: ${YY} <br/> Sample Point Number: ${Sample Point Number} <br/> Point Collected: ${Point Collected} <br/>  Major Rabi Crops: ${ Major Rabi Crops} <br/> Major Summer Crop: ${Major Summer Crop} <br/> Soil Type: ${Soil Type} <br/> Major Kharif Crops: ${Major Kharif Crops}");
                          feature.setInfoTemplate(taxParcelTemplate);
                      }
                      //else if (layerName === 'Grid') {
                      //    console.log(feature.attributes.objectid);
                      //    var buildingFootprintTemplate = new InfoTemplate("",
                      //      "OBJECTID: ${OBJECTID}");
                      //    feature.setInfoTemplate(buildingFootprintTemplate);
                      //}

                      return feature;
                  });
              });

            map.infoWindow.setFeatures([deferred]);
            map.infoWindow.show(event.mapPoint);
        }

谁能帮我解决这个问题。我正在使用http://developers.arcgis.com/javascript/sandbox/sandbox.html?sample=find_drilldown

【问题讨论】:

    标签: arcgis arcgis-js-api


    【解决方案1】:

    添加图片非常简单。只需将其添加到infoTemplateHere is an example 添加到您上面引用的指南中的图像。唯一添加的是第 101 行:

    template += "<img src='http://webapps-cdn.esri.com/Apps/MegaMenu/img/logo.jpg' /><br>";
    

    src 显然是图像的位置。

    如果您特别需要代码方面的帮助,请创建一个 fiddle 以便更容易使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-01
      • 2022-10-04
      • 1970-01-01
      • 1970-01-01
      • 2021-09-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多