Can a layer change the infowindow size?

3806
4
Jump to solution
04-08-2015 10:13 AM
DavidElies
New Contributor III

A layer (or even individual graphics) can have an info template that describes the content of the infowindow, but I want different layers to have different size info windows.  Is it possible for layers to specify the size of the info window used when clicking on their graphics?  Mostly I want to make sure that layers that don't specify a size don't get the super-wide info window I want for one of my layers.

0 Kudos
1 Solution

Accepted Solutions
SteveCole
Frequent Contributor

You can do this. I don't know if there are additional ways of doing this but I do this using a click event handler for each layer:

        theLayer.on("click", function(evt) {
            map.infoWindow.resize(350, 275);
        });

If you wanted to reset the infoWindow back to a default size, you can do that in a similar manner:

        map.infoWindow.on("hide", function(evt) {
            map.infoWindow.resize(400,300);
        });

Just tweak the height/widths until you're happy.

Steve

View solution in original post

4 Replies
SteveCole
Frequent Contributor

You can do this. I don't know if there are additional ways of doing this but I do this using a click event handler for each layer:

        theLayer.on("click", function(evt) {
            map.infoWindow.resize(350, 275);
        });

If you wanted to reset the infoWindow back to a default size, you can do that in a similar manner:

        map.infoWindow.on("hide", function(evt) {
            map.infoWindow.resize(400,300);
        });

Just tweak the height/widths until you're happy.

Steve

DavidElies
New Contributor III

That's a clever way of adjusting the infowindow size.  I was hoping there was a way for a layer to request that on its own (similar to the way the info template works).  I will do this if there is no API way of making this happen.

0 Kudos
SteveCole
Frequent Contributor

It's the way I've always done it but I don't know if it's the right way.

0 Kudos
TimWitt2
MVP Alum

As far as I know this is the only way to do it.