Constrain InfoWindow to window size

3425
21
Jump to solution
02-21-2012 11:28 AM
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
Is there a way to constrain the InfoWindow, when visible, to the size of the browser window?  If a user clicks a point that is close to the top of the browser window, the InfoWindow expands past the top of the page.
[ATTACH=CONFIG]12103[/ATTACH]

Ideally I'd like to shift the map south so that the entire InfoWindow displays.
[ATTACH=CONFIG]12104[/ATTACH]

Any ideas?
0 Kudos
1 Solution

Accepted Solutions
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
What I ended up doing is building an envelope that compensated for the width & height of the infoWindow.  If the anchor point of the infowindow fell outside the envelope then the map would pan to center the anchor on the page.  If the anchor point of the infoWindow fell inside the envelope, then the map does not pan since the infoWindow will completely show.  Every time the extent of the map changes, the envelope refreshes.  Seems to work perfectly.

View solution in original post

0 Kudos
21 Replies
by Anonymous User
Not applicable
Original User: jenniferdnery

This is the current behavior of InfoWindow, it does not pan the map or open from bottom to fit the application. If you wish to change this, you can download source from: http://esrisilverlight.codeplex.com/

You can also probably change the size of element inside DataTemplate or use ScrollViewer.
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
What I ended up doing is building an envelope that compensated for the width & height of the infoWindow.  If the anchor point of the infowindow fell outside the envelope then the map would pan to center the anchor on the page.  If the anchor point of the infoWindow fell inside the envelope, then the map does not pan since the infoWindow will completely show.  Every time the extent of the map changes, the envelope refreshes.  Seems to work perfectly.
0 Kudos
by Anonymous User
Not applicable
Original User: brunno14

Is there a way to constrain the InfoWindow, when visible, to the size of the browser window?  If a user clicks a point that is close to the top of the browser window, the InfoWindow expands past the top of the page.
[ATTACH=CONFIG]12103[/ATTACH]

Ideally I'd like to shift the map south so that the entire InfoWindow displays.
[ATTACH=CONFIG]12104[/ATTACH]

Any ideas?


Hi..

Could you please post the code showing how you did this InfoWindow?

I'm having some problems to implement this control...

Thanks.
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
Hi..

Could you please post the code showing how you did this InfoWindow?

I'm having some problems to implement this control...

Thanks.


Are you having problems implementing a simple infoWindow?  If so, then check this out:http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#InfoWindowSimple

0 Kudos
by Anonymous User
Not applicable
Original User: brunno14

Are you having problems implementing a simple infoWindow?  If so, then check this out:http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#InfoWindowSimple



I saw this sample, the problem is that I'm trying to implement the InfoWindow in a User Control, in a different page than the MapPage.

Here's a piece of code of my User Control:

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>

            <DataTemplate x:Name="MyFeatureLayerInfoWindowTemplate">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="TEST" Foreground="Black" FontSize="12" />
                </StackPanel>
            </DataTemplate>           

        </Grid.Resources>
        <esri:InfoWindow x:Name="MyInfoWindow"
                         Padding="2"
                         CornerRadius="20" 
                         Background="LightSalmon"
                         ContentTemplate="{StaticResource MyFeatureLayerInfoWindowTemplate}" />
   
    </Grid>


And in the click event of the graphic, that should show the InfoWindow, I put the following code:

        void graphic_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Graphic gra = sender as Graphic;
            MyInfoWindow MyInfo = new MyInfoWindow();
            MyInfo.MyInfoWindow.Content = gra.Attributes;
            MyInfo.MyInfoWindow.Anchor = gra.Geometry as MapPoint;

            MyInfo.MyInfoWindow.Map = CurrentPage.myMap;
            MyInfo.MyInfoWindow.IsOpen = true;
        }


I put a breakpoint inside the click event, and when I click in the graphic, it hits the breakpoint, but no InfoWindow appears...

Am I missing something?

Thanks.
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
Is the geometry of your graphic a point (MapPoint)?  Make sure you are returning map coords.  Also, not sure if this could be a problem, but you aren't specifying the ContentTemplate of your infoWindow... 
You need:  MyInfoWindow.ContentTemplate = TryCast(LayoutRoot.Resources("InfoWindowTemplate"),system.windows.datatemplate)
(sorry, I am a VB.NET guy :p)
0 Kudos
by Anonymous User
Not applicable
Original User: brunno14

While debugging I can see the values, and it shows the following:

Point[X=-46.6344223022461, Y=-23.5520210266113, WKID=4326]

The values are right, so this wouldn't be a problem, right?

And I'm specifying the ContentTemplate of my InfoWindow in the XAML code:

<esri:InfoWindow x:Name="MyInfoWindow"
                         Padding="2"
                         CornerRadius="20" 
                         Background="LightSalmon"
                         ContentTemplate="{StaticResource MyFeatureLayerInfoWindowTemplate}" />


Do I need to specify it again in my code?

I'm new to this stuff, sorry for the inconvenience 😛
0 Kudos
deleted-user-ATjHIWsdQYmT
Occasional Contributor III
I have the ContentTemplate defined in my codebehind and my XAML.  I don't know if it's necessary, but that's what I have.

Couple more things to try:
1. Is  the infoWindow opening BEHIND the map?  check the zIndex
2.  Is your map contained inside a Grid with multiple rows/columns?  I had a lot of problems with opening an InfoWindow when the map was inside a specific grid cell.(http://forums.arcgis.com/threads/23081-How-do-I-control-the-Infowindow-height?p=100995)
0 Kudos
by Anonymous User
Not applicable
Original User: brunno14

Ok. I've set the ContentTemplate in code-behind. No changes.

1- I don't think my InfoWindow is opening behind the map. There's no zIndex set in myMap and looks like there's no zIndex property in the InfoWindow aswell.

2- Yes, my map is contained inside a Grid. I saw the thread you refer, but in my case the infowindow doesnt even appear, while in the other cases the infowindow is appearing in the wrong position...

Thanks for trying to help me.
0 Kudos