Select to view content in your preferred language

Don't want a title on infoTemplate, but still want X to close

6610
38
Jump to solution
10-21-2015 08:31 AM
TracySchloss
Honored Contributor

I would rather not have a title to my infoTemplate window.  I don't need to repeat the name of the location again, when I want it as part of the content and if you title it something like "Location Information", all I can think is "Duh, of course it's the location information, I just clicked it!".  If you don't set any title, you still get one, but it's set to ObjectID, which not many people care to see.

Trying infoTemplate.setTitle("") you still get objectid as your title.  If you set it to infoTemplate.setTitle(" "), with a blank space, then you can have no title. However now the whole header is left off, and I still want it to have an X to close, along with any next, previous arrow that might come with having multiple features selected.

I looked at the infoWindowLite, but I don't like the big red X as a substitute for an anchor pointing to an element.

I'm creating a plain infoTemplate, then populating it with a function.  I've tried map with a popup parameter and without one and that makes no difference.

var infoTemplate = new InfoTemplate();

 var   featureLayer =  new FeatureLayer(pathName+"/arcgis/rest/services/MDA/sampleGeocodeEdit/FeatureServer/0",{
        id:"featureLayer",
        outFields:['*'],
        infoTemplate:infoTemplate
     });
     featureLayer.renderer = renderer;
     featureLayer.setSelectionSymbol(highlightMarkerSymbol);
     
 //edit the selected feature    
     var selectQuery = new Query();
     
     on(featureLayer, "click", function(evt){
       formatString = "";
       var  objectId = evt.graphic.attributes[featureLayer.objectIdField];
        selectQuery.objectIds = [objectId];
        featureLayer.selectFeatures(selectQuery);      
     });
    on(featureLayer, "error", function (err){
      console.log("error with featureLayer; " + err.message);
    });
    
    on(featureLayer, 'selection-complete', setWindowContent);
   
function setWindowContent(results){
   map.infoWindow.resize(240, 100);
     var imageString = "<table><tr>";
     var imageStyle = "alt='site image' style='height=:40px width:40px float:left'";
     var deferred = new Deferred;
      var graphic = results.features[0];
      var  objectId = graphic.attributes[featureLayer.objectIdField]; 
         
      featureLayer.queryAttachmentInfos(objectId).then(function(response){
          var imgSrc;
          if (response.length === 0) {
              deferred.resolve("no attachments");
          }
          else {
              imgSrc = response[0].url;
              imageString += "<td><img src='" + imgSrc + "' " + imageStyle + "></td>";
              formatString += imageString;
              domConstruct.empty("attachPreviewDiv");
              domConstruct.create("img", {
                  src: imgSrc
              }, "attachPreviewDiv");
          }
          formatString += "<td><b>" + graphic.attributes.Facility + "</b><br/>" + graphic.attributes.Address + "<br/>" +
          graphic.attributes.City +  ", " + graphic.attributes.State +
          "<td></tr></table>";
          
          infoTemplate.setContent(formatString);
          infoTemplate.setTitle(" ");
      });
   map.enableMapNavigation();
 }    
0 Kudos
38 Replies
TracySchloss
Honored Contributor

To fix the actionPane that was hidden, I added this to my setWindowContent function:

           var t = query(".actionList");

          domClass.remove(t[0], "hidden");

Now I need to go back into my projects that use Bootstrap and see if this technique works there.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Tracy,

   Quick question, why do you want the action pane showing? The zoom button does not function and the action pane was hidden because you where not setting the popups features using setFeatures method.

0 Kudos
TracySchloss
Honored Contributor

Rats, I didn't check that.   This all started because the standard methods of displaying the infoWindow with a function fell apart once I wanted to display the attachment of the featureLayer as part of it.  It worked fine in Chrome, but in IE, it didn't.  The first click displayed content that looked like what you get which you just set attributes {'*'} and then all subsequent clicks gave information from the previous selection, not what I'd just clicked. 

  I posted a thread about it, but got no replies, so I changed it around.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Tracy,

   I saw that thread and tested but I never found what was going wrong in IE or a workaround.

0 Kudos
TracySchloss
Honored Contributor

Well, if you can't figure it out, I guess there's not a lot of point in me spending more time on it.  I was sure I just had something out of sequence.  I looked into dojo/aspect, but I couldn't wrap my head around it enough to try it.  I wondered if having the image URL beforehand would make a difference.  Then I wouldn't need to call   queryAttachmentsInfo from within my setWindowContent function. That's the only thing that's different than a lot of other infoTemplates I've created.

Since the dropped 'zoom to' was also an issue with the maps I'm making using Bootstrap, I will just add the link and function I made for it.

RobertScheitlin__GISP
MVP Emeritus

Tracy,

   I do believe that the issue is a timing issue but I did not spend a lot of time looking at it as you seems to move on from the issue so quickly.

0 Kudos
KellyHutchins
Esri Notable Contributor

Do you have a link to the thread that describes the issue you are having with IE and the popup content?

0 Kudos
TracySchloss
Honored Contributor

I'll have to recreate my jsBin, I'll bet.  I had several things posted there that were nearly all the same. I deleted a few yesterday because I'd managed to break some.

Using function for infoTemplate, content is for the wrong feature, only in IE

This isn't a 'real' project yet, but a piece of functionality I'm going to need a little later. When I didn't get a reply, I came up with my workaround and let it go.   It feels like if you don't get a response in the first few days from a posting, you're never going to.   People don't scroll too far down.

0 Kudos
TracySchloss
Honored Contributor

Here's the version that uses infoTemplate, as opposed to setting the content in map.InfoWindow.  It doesn't work right in IE:

JS Bin - Collaborative JavaScript Debugging

Not only did I want the attachment as an image in the window, I also wanted to display it with the image on the left and the information next to it on the right.  Because of this, I formatted it as a table.  I didn't think I could achieve the same look using PopupTemplate.

0 Kudos
KellyHutchins
Esri Notable Contributor

Tracy Schloss

I'll take a look at the IE issue above and see if I can find a solution. In the meantime here's a revised version of your code that adds the zoom to capability to your popup.

JS Bin - Collaborative JavaScript Debugging