Showing photos in Tax Parcel Viewer Layers

2059
1
01-28-2013 09:50 AM
Labels (1)
KenBurcham
Occasional Contributor
Good morning!

We wanted to show a photo in our buildings layer (added to the Tax Parcel Viewer in place of the demo "foreclosures" layer).  I made the appropriate change to utils.js and thought I'd share it in case anyone else would like to do something similar.

Here's a pic of how it looks finished:
[ATTACH=CONFIG]21138[/ATTACH]
Here is how I wanted my config.js to look.  I wanted to just say "isPhoto: true" and have it make the img html tag for me:
{ DisplayText: "Photo:", FieldName: "${Photo}", DataType: "string", isPhoto: true },

And here's the code change in the QueryLayer function in utils.js (around line 1040). You just need to add another "if else" to deal with that "isPhoto=true" parameter:
if (layerInfo.Fields[index].isDate) {                 var date = new js.date();                 var utcMilliseconds = Number(dojo.string.substitute(layerInfo.Fields[index].FieldName, resultSet.attributes));                 td1.innerHTML = dojo.date.locale.format(date.utcTimestampFromMs(utcMilliseconds), { datePattern: datePattern, selector: "date" });             }             else if (layerInfo.Fields[index].DataType == "double") {                 var formattedValue = dojo.number.format(value, { pattern: "#,##0.##" });                 td1.innerHTML = currency + " " + formattedValue;             }    else if (layerInfo.Fields[index].isPhoto) { //kb: here is our code to handle photos     td1.innerHTML = "<a href='"+value+"' target=_blank><img height='140' src='" + value + "'/></a>";    }             else {                 td1.innerHTML = dojo.string.substitute(layerInfo.Fields[index].FieldName, resultSet.attributes);             }

This will make the photo thumbnail link to the actual photo so that clicking on it will open the photo in a new window.

Cheers!

ken.
0 Kudos
1 Reply
LindsayThomas
Esri Contributor
Ken,

Thanks for sharing. We love to see enhancements for our applications.

Cheers,
Lindsay
0 Kudos