2016-02-05 33 views
1

我有一個標識符,如果我點擊特定點,它將顯示該點的所有信息。現在問題是需要爲每個點添加圖像,如果我點擊該點它會顯示信息以及image.Currently我使用如何在標識符彈出框中添加和顯示圖像

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

回答

0

添加圖像是非常簡單的。只需將它添加到infoTemplate。添加到您在上面引用的指南中的圖像的Here is an example。唯一添加的是101行:

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

其中src顯然是圖像。

如果您需要特別幫助您的代碼,請創建一個小提琴,以便更輕鬆地使用它。

相關問題