Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

How can I set the size of an infoWindow dynamically, based on the length of its Title, when the Title isn't known until the user clicks on a map feature?

Take the map here as an example - how could you resize the popup infoWindow to accommodate varying Title lengths?

This map uses the ${Name} notation to represent the Title field, with the field value substituted into the infoWindow when the feature is clicked.

The infoWindow has a fixed size (set using map.infoWindow.resize(250,95)). Since the length of the title isn't known until the feature is clicked, how is it possible to resize the infoWindow based on the length of the Title?

Using ArcGIS Server 10 with the JavaScript API 2.3

share|improve this question
    
u ever resolve this one Stephen? –  Simon Jan 9 '13 at 5:12
1  
@Simon nope, I never got around to resolving this as it dropped off my priority list. Perhaps you could listen for when the infoWindow opens, evaluate the length of the title, and resize according? –  Stephen Lead Jan 9 '13 at 5:24
add comment

1 Answer 1

Here is a jsFiddle example. Try clicking on Ohio for a smaller info window and then South Carolina for a larger info window. Hope this helps!

http://jsfiddle.net/8PntC/

share|improve this answer
    
Good one but the small window is not re-sizable working on your fiddle –  Sunil Jul 25 '13 at 13:33
    
@Sunil, not sure what you mean. The small window appears when you click a state that has a name less than 10 chars, like Ohio, and only draws a box with a width of 100px. Whereas as state with a name longer than 10 chars, like South Carolina, draws a box with a width of 500px. Let me know if you are seeing something else, or if I misunderstood your original question. –  CLJ Jul 26 '13 at 14:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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