AnsweredAssumed Answered

two different infotemplates for two different feature layers?

Question asked by reseburgn on Jan 27, 2016
Latest reply on Jan 28, 2016 by reseburgn


I am trying to make a basic web page.  I have two feature layers, a polygon feature layer and then a point feature layer, both in the same mapping service:


mapping serviceA/0 = polygon

mapping serviceA/1 = point


in my app, which i am creating using Javascript API obviously, i want to have a different infowindow pop up for when a user clicks a point vs a polygon.  I though i could just define the templates differently when i declare the feature layer, code below - but it ends up defaulting to the second info template. I know it can be done because i see it all the time, i just don't know how to do it with the javascript API.  All of the samples and such just show how to work with info templates for one layer, not two.  Can anyone help me?


            var popup = new Popup({

              fillSymbol: new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,

                new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,

                  new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25]))

          }, domConstruct.create("div"));


                map = new Map("map", {

              sliderOrientation: "vertical",

              center: [-122.15, 37.85],

              zoom: 11,

              basemap: "streets",

              infoWindow: popup,

              logo: false,

              showLabels: true




          // Polygon template

          var template = new InfoTemplate();

          template.setContent("Number of Main Breaks: ${OMGDB.%MainBreaks.GWO}");

          template.setTitle("BMAP ${OMGDB.BMAP.BMAP}");


          // Point template

          var gwoTemplate = new InfoTemplate();

          template.setContent("GWO Number: ${GWO}");

          template.setTitle("BMAP: ${BMAP}");


                // Polygon Feature Layer

              var breaks = new FeatureLayer("http://localmapservice/MapServer/2", {

              mode: FeatureLayer.MODE_ONDEMAND,

              id: "breaks",

              className: "text",

              infoTemplate: template,

              outFields: ["*"]



             // Point Feature Layer

          var breaksplot = new FeatureLayer("http:http://localmapservice/MapServer/0", {

              mode: FeatureLayer.MODE_ONDEMAND,

              id: "breaksplot",

              infoTemplate: gwoTemplate,

              outFields: ["GWO", "BMAP"]



i then tried adding the following lines hoping it would do something but alas, it did not:

          dojo.connect(breaks, "onClick", function () {

              //map.infoWindow.resize(100, 100)

              breaks.infoTemplate = template;



          dojo.connect(breaksplot, "onClick", function () {

              breaksplot.infotempalte = gwoTemplate;