AnsweredAssumed Answered

Editor conflicts with unrelated feature layer's popup template

Question asked by dualinventive on Feb 25, 2015
Latest reply on May 19, 2015 by mstranovsky

I have an issue where using the Editor + TemplatePicker causes the feature layer's (that is not editable) pop up template to not display or only briefly when using this code:

 

        featureLayer.on("click", function(evt) {
            var center = evt.graphic.geometry;
            map.infoWindow.setFeatures([evt.graphic]);
            map.infoWindow.show(center);
          });

 

Also I have a problem where the label layer's labels are editable, I managed to disable this by adding the code below. I don't know if there's a better way.

 

labelLayer.disableMouseEvents();

 

The full code I inserted in this sandbox after settings variable:

 //create a feature collection for the flickr photos
          var featureCollection = {
            "layerDefinition": null,
            "featureSet": {
              "features": [],
              "geometryType": "esriGeometryPoint"
            }
          };
          featureCollection.layerDefinition = {
            "geometryType": "esriGeometryPoint",
            "objectIdField": "ObjectID",
            "drawingInfo": {
              "renderer": {
                "type": "simple",
                "symbol": {
                  "type": "esriPMS",
                  "url": "images/flickr.png",
                  "contentType": "image/png",
                  "width": 15,
                  "height": 15
                }
              }
            },
            "fields": [{
              "name": "ObjectID",
              "alias": "ObjectID",
              "type": "esriFieldTypeOID"
            }, {
              "name": "description",
              "alias": "Description",
              "type": "esriFieldTypeString"
            }, {
              "name": "title",
              "alias": "Title",
              "type": "esriFieldTypeString"
            }]
          };
            
          //define a popup template
          var popupTemplate = new PopupTemplate({
            title: "{title}",
            description: "{description}"
          });
  
          //create a feature layer based on the feature collection
          featureLayer = new FeatureLayer(featureCollection, {
            id: 'flickrLayer',
            infoTemplate: popupTemplate
          });
          
          featureLayer.on("click", function(evt) {
            var center = evt.graphic.geometry;
            map.infoWindow.setFeatures([evt.graphic]);
            map.infoWindow.show(center);
          });
  
          map.addLayer(featureLayer);
    
          var symbol = new esri.symbol.TextSymbol();
          var renderer = new esri.renderer.SimpleRenderer(symbol);
          var labelLayer = new esri.layers.LabelLayer();
          labelLayer.addFeatureLayer(featureLayer, renderer, "${CITY_NAME}");
          map.addLayer(labelLayer);
    
          requestPhotos();
          function requestPhotos() {
            //get geotagged photos from flickr
            //tags=flower&tagmode=all
            var requestHandle = esriRequest({
              url: "http://api.flickr.com/services/feeds/geo?&format=json",
              callbackParamName: "jsoncallback"
            });
            requestHandle.then(requestSucceeded, requestFailed);
          }


          function requestSucceeded(response, io) {
            //loop through the items and add to the feature layer
            var features = [];
            arrayUtils.forEach(response.items, function(item) {
              var attr = {};
              attr["description"] = item.description;
              attr["title"] = item.title ? item.title : "Flickr Photo";
    
              var geometry = new Point(item);
    
              var graphic = new Graphic(geometry);
              graphic.setAttributes(attr);
              features.push(graphic);
            });
    
            featureLayer.applyEdits(features, null, null);
          }
    
          function requestFailed(error) {
            console.log('failed');
          }
    
          labelLayer.disableMouseEvents();

Outcomes