I'm trying to display an image in a popup, I've read the documentation, I've seen the code of some samples (and also made some attempts using ImageValue and ImageContent), but when I click on the map element with the popup, the image doesn't show. I can't figure out what I'm doing wrong.
Here is my code now and here is my popup when I click on a point:
var attr = {
Lat: arr[i][0], //latitude
Lng: arr[i][1], //longitude
Image: "localimage.jpg" //image in same folder
};
var template = new PopupTemplate({
title: "Lat: {Lat} Lng: {Lng}",
mediaInfos: [{
"title": "",
"caption": "",
"type": "image",
"value": {
"sourceURL": "{Image}"
}
}]
});
//when I click on this point after I've added it to the map,
//the image doesn't show
var pointGraphic = new Graphic({
geometry: point,
symbol: pictureMarkerSymbol, //custom marker
attributes: attr,
popupTemplate: template
});
EDIT: I've re-read some samples, trying to understand what I was missing and keeping in mind the answer given here, in the end the solution was that I've missed some parenthesis:
var template = new PopupTemplate({
title: "Lat: {Lat} Lng: {Lng}",
content: [{ //Missed [ here
type: "media",
mediaInfos: [{
title: "",
caption: "",
value: {
sourceURL: "{Image}"
}
}]
}] //Missed ] here
});
Thanks for the reply, hope this helps someone in the future