AnsweredAssumed Answered

Whats wrong with my logic?

Question asked by rralbritton on Apr 21, 2016
Latest reply on Apr 28, 2016 by kenbuja

I am trying to set the contents of an infoTemplate based on an if/else statement, however, its not giving me the results that I would expect. Certain fields in the 'thumbnails' field contain a field that is call 'NoImage2.jpg'. If the field contains this title I want this field removed from the infotemplate window. When I test the logic, the infotemplate always returns the else statement. If I remove the else statement and have the function only evaluate the if statement, the windows comeback blank, even for the objects that it should apply to. I'm clearly overlooking something but I can't figure it out. Thanks in advance.


 map = new Map("map",{
          basemap: "streets",
          center:[-111.836, 40.765], //long, lat
          zoom: 14
            bldgContentObject = {
            objectid: '${OBJECTID}',
            formalName: '"${formal_name:formatStructureNameForThumbnailModal}"',
            informalName: '"${informal_name:formatStructureNameForThumbnailModal}"',
            streetAddress: '${street_address}',
            city: '${city}',
            state: '${state}',
            zipCode: '${zip_code}',
            thumbnails: '${thumbnails}',
            buildingNumber: '${building_number}',
            abbreviation: '${abbreviation}',
            lattitude: '${lattitude:gsvLat}',
            longitude: '${longitude:gsvLon}',
            gsvHeading: '${gsv_heading:gsvHeading}',
            gsvPitch: '${gsv_pitch:gsvPitch}'
        symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_NULL,
        new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID)); //new Color([0,0,0])), new Color([0,0,0]));
        //infoTemplate = new InfoTemplate("${informal_name}", "<b>BN: </b>${building_number}<br><b>Abbrv: </b>${abbreviation}<br><b>Thumbnail: </b>${thumbnails}<br>");
        infoTemplate = new InfoTemplate();
        infoTemplate.setTitle (bldgContentObject.informalName);
        var infoContent1 = "<b>BN: </b>"+bldgContentObject.buildingNumber+"<br><b>Thumbnail: </b>"+bldgContentObject.thumbnails;
      var infoContent2 = "<b>BN: </b>"+bldgContentObject.buildingNumber;
        //infoTemplate.setContent("<b>BN: </b>${building_number}<br><b>Abbrv: </b>${abbreviation}<br><b>Thumbnail: </b>${thumbnails}<br>"); //Works
        //infoTemplate.setContent(infoContent1); //This logic works
        function templateContent (){
    //return bldgContentObject.thumbnails; //name in the thumbnails field (string)
        if (bldgContentObject.thumbnails === "'NoImage2.jpg'"){return infoContent2;} //returns a content window with only the title
        //if (bldgContentObject.thumbnails === "NoImage2.jpg"){return infoContent2;}) //same results as above
        //if bldgContentObject.thumbnails === '"NoImage2.jpg"'){return infoContent2;}// same results as above
    else {return infoContent1;}
        map.on("click", doQuery);
        queryTask = new QueryTask("");
        queryTask.on("complete", addToMap);
        query = new Query();
        query.returnGeometry = true;
        query.outFields = ["*"];
          function doQuery(evt) {
        //clear currently displayed results;
        query.geometry = evt.mapPoint;
            query.outSpatialReference  = map.spatialReference;
        function addToMap(results) {           
        var featureArray = results.featureSet.features;
            var feature = featureArray[0];          

    <div id="map"></div>