0

I noticed that when you use IdentifyTask to identify features at a given point on the map, it shows an InfoWindow with multiple pages. I was wondering if it was possible to add pages to an InfoWindow without explicitly having to select an area with multiple features.

0

This was a little bit of a hack, taking advantage of the InfoWindow's feature display to add multiple pages. You're essentially tricking it into believing you've clicked an area with multiple features.

var fakeFeatures = [];
var page1 = {
    getLayer: function () {}, // as long as it returns null, you're good
    attributes: {}, // this does not influence the content in the popup
    getInfoTemplate: function () {
        return { title: "test", content: "${*}", declaredClass: "esri.InfoTemplate" };
    // yes, you do need 'declaredClass', otherwise the title will not show up
    },
    getTitle: function () { return this.getInfoTemplate().title; },
    getContent: function () { return "HTML</br>" }
};
fakeFeatures.push(page1);

var page2 = {
    getLayer: function () {},
    attributes: {},
    getInfoTemplate: function () {
        return { title: "test", content: "${*}", declaredClass: "esri.InfoTemplate" };
    },
    getTitle: function () { return this.getInfoTemplate().title; },
    getContent: function () { return "HTML</br>" }
};
fakeFeatures.push(page2);
map.infoWindow.setFeatures(fakeFeatures);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.