Select to view content in your preferred language

setTitle not working in infoTemplate

1329
3
Jump to solution
04-25-2013 05:46 AM
KenBuja
MVP Esteemed Contributor
In my app using the 3.4 API, I'm attempting to set the title on an infoTemplate. I've tried

var infoTemplate = new esri.InfoTemplate("Title", contentString);

and

var infoTemplate = new esri.InfoTemplate();
var titleText = "<div>" + "Title" + "</div>"
infoTemplate.setTitle(titleText); //also tried infoTemplate.setTitle("Title");
infoTemplate.setContent(contentString);

but neither of those set the title. The contentString shows up properly, though.
0 Kudos
1 Solution

Accepted Solutions
ReneeMaxwell
Regular Contributor
I've have encountered this bug in 3.3 as well. I discovered that you can workaround it by setting the title AFTER you call setFeatures. Otherwise, any other configuration you employ to set the title will show up blank.

My fix:

var selFeature = results[0].feature;
map.graphics.add(selFeature);
var selLayer = results[0].layerName;
selFeature.setInfoTemplate(template);
map.infoWindow.setFeatures([selFeature]);
//** IMPORTANT! **/
// YOU MUST SET THE TITLE **AFTER** CALLING SETFEATURES
map.infoWindow.setTitle(selLayer);
map.infoWindow.show(evt.mapPoint);

View solution in original post

0 Kudos
3 Replies
JohnGravois
Deactivated User
how is your app different than this sample?
0 Kudos
KenBuja
MVP Esteemed Contributor
Here's a working example that illustrates the issue.
0 Kudos
ReneeMaxwell
Regular Contributor
I've have encountered this bug in 3.3 as well. I discovered that you can workaround it by setting the title AFTER you call setFeatures. Otherwise, any other configuration you employ to set the title will show up blank.

My fix:

var selFeature = results[0].feature;
map.graphics.add(selFeature);
var selLayer = results[0].layerName;
selFeature.setInfoTemplate(template);
map.infoWindow.setFeatures([selFeature]);
//** IMPORTANT! **/
// YOU MUST SET THE TITLE **AFTER** CALLING SETFEATURES
map.infoWindow.setTitle(selLayer);
map.infoWindow.show(evt.mapPoint);
0 Kudos