1

I'm using ArcGIS JS API 3.24 and I got an error saying that

Uncaught TypeError: cellInfoTemplate.setTitle is not a function

But I'm sure that I have already included esri/InfoTemplate in my require. Here is more:

 require([
  "esri/map", "esri/layers/FeatureLayer", "esri/InfoTemplate",
  "esri/tasks/GeometryService", "esri/layers/ArcGISDynamicMapServiceLayer",
  "esri/layers/TableDataSource", "esri/layers/QueryDataSource", "esri/layers/LayerDataSource", "esri/layers/DynamicLayerInfo",
  "esri/symbols/SimpleFillSymbol", "esri/renderers/SimpleRenderer", "esri/layers/LayerDrawingOptions",
  "esri/symbols/PictureMarkerSymbol", "esri/symbols/SimpleLineSymbol",
  "esri/symbols/SimpleMarkerSymbol", "esri/renderers/UniqueValueRenderer",
  "esri/config",
  "esri/Color", "dojo/domReady!"
], function (
  Map, Layers, FeatureLayer, InfoTemplate,
  GeometryService, ArcGISDynamicMapServiceLayer,
  TableDataSource, QueryDataSource, LayerDataSource, DynamicLayerInfo,
  SimpleFillSymbol, SimpleRenderer, LayerDrawingOptions,
  PictureMarkerSymbol, SimpleLineSymbol, SimpleMarkerSymbol, UniqueValueRenderer,
  esriConfig,
  Color
) { 
    var cellInfoTemplate = new InfoTemplate();
    cellInfoTemplate.setTitle("Details");
    cellInfoTemplate.setContent(getCellHTML());

    var featureLayer = new esri.layers.FeatureLayer("myUrl", {
        "opacity": 0.6,
    });

    featureLayer.setInfoTemplates(infoTempDict);

    function getCellHTML(){ ... }
    ... other codes ...
 }

And if I avoid using .setTitle and .setContent with

var cellInfoTemplate = new InfoTemplate("Details",getCellHTML());

It will return me

Uncaught TypeError: featureLayer.setInfoTemplates is not a function

So can anyone tell me how to solve the error?

0

OK, after some testing, I got a little change to let my codes work:

The function .setInfoTemplates( {layers: InfoTemplates} ) should work on a dynamicLayer. For a single featureLayer, I need to use

featureLayer.setInfoTemplate(InfoTemplate) 

In this way, no error in console and info window will jump out correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.