HTML+JS: how display raster field in InfoWindow

4404
7
12-15-2014 04:48 AM
AlekseyShulga
New Contributor II

Hello,

 

How can I do it?

 

In context of InfoWindow

<img src=\"${Photo}\" />

not work...

Tags (2)
0 Kudos
7 Replies
ReneRubalcava
Frequent Contributor

What is the value of the "Photo" field? Is it a url? Is it a base64 encoded string?

If you could provide a sample that may help.

0 Kudos
AlekseyShulga
New Contributor II

no, it is type "Raster" in ArcGIS.

0 Kudos
AlekseyShulga
New Contributor II

in the REST I see this field as esriFieldTypeBlob. I found sample:

<img src="data:image/png;base64,${Photo}" />

but image not display

0 Kudos
OwenEarley
Occasional Contributor III

You would need to convert your raster Blob data to base64 before you apply it to the image src as Rene suggests.

One way I have seen to do this on the client side is using the HTML5 canvas object. For example: javascript - How to get the right image data in base64 format using HTML5 canvas - Stack Overflow

Another option may be using the Dojo toolkit: dojox.encoding.base64 — The Dojo Toolkit - Reference Guide

(info from this post: How to read FieldTypeBlob from graphic.attributes).

Using the HTML5 canvas object will have compatibility issues with older browsers.

Encoding the Blob to base64 server-side is relatively simple but it looks like you need to do this on the client.

0 Kudos
AlekseyShulga
New Contributor II

I read this post How to read FieldTypeBlob from graphic.attributes and I try this, but image not display (I wrote this above)

0 Kudos
AlekseyShulga
New Contributor II

May be I define dojox incorect?

require([..., "dojox/encoding/base64", ...],

function (..., base64, ...) {}

0 Kudos
AlekseyShulga
New Contributor II

Oh, no... I was wrong... field type is esriFieldTypeRaster

0 Kudos