+ Reply to Thread
Results 1 to 22 of 22

Thread: Constrain InfoWindow to window size

  1. #1
    Andrew Bowne
    Join Date
    Oct 2009
    Posts
    289
    Points
    96
    Answers Provided
    19


    0

    Default Constrain InfoWindow to window size

    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.
    Click image for larger version

Name:	OffScreen.PNG
Views:	119
Size:	89.1 KB
ID:	12103

    Ideally I'd like to shift the map south so that the entire InfoWindow displays.
    Click image for larger version

Name:	Correct.PNG
Views:	105
Size:	182.5 KB
ID:	12104

    Any ideas?

  2. #2
    Jennifer Nery

    Join Date
    May 2010
    Posts
    2,449
    Points
    289
    Answers Provided
    51


    0

    Default Re: Constrain InfoWindow to window size

    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.
    Jennifer Nery
    Software Developer
    ArcGIS API for SL/WPF/WP7

  3. #3
    Andrew Bowne
    Join Date
    Oct 2009
    Posts
    289
    Points
    96
    Answers Provided
    19


    0
    This post is marked as the answer

    Default Re: Constrain InfoWindow to window size

    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.

  4. #4
    Brunno Bassan
    Join Date
    Mar 2012
    Posts
    10
    Points
    0
    Answers Provided
    0


    0

    Default Re: Constrain InfoWindow to window size

    Quote Originally Posted by andrewb View Post
    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.
    Attachment 12103

    Ideally I'd like to shift the map south so that the entire InfoWindow displays.
    Attachment 12104

    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.

  5. #5
    Andrew Bowne
    Join Date
    Oct 2009
    Posts
    289
    Points
    96
    Answers Provided
    19


    0

    Default Re: Constrain InfoWindow to window size

    Quote Originally Posted by brunno14 View Post
    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


  6. #6
    Brunno Bassan
    Join Date
    Mar 2012
    Posts
    10
    Points
    0
    Answers Provided
    0


    0

    Default Re: Constrain InfoWindow to window size

    Quote Originally Posted by andrewb View Post
    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:

    Code:
        <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:

    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.

  7. #7
    Andrew Bowne
    Join Date
    Oct 2009
    Posts
    289
    Points
    96
    Answers Provided
    19


    0

    Default Re: Constrain InfoWindow to window size

    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 )

  8. #8
    Brunno Bassan
    Join Date
    Mar 2012
    Posts
    10
    Points
    0
    Answers Provided
    0


    0

    Default Re: Constrain InfoWindow to window size

    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:

    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

  9. #9
    Andrew Bowne
    Join Date
    Oct 2009
    Posts
    289
    Points
    96
    Answers Provided
    19


    1

    Default Re: Constrain InfoWindow to window size

    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/230...eight?p=100995)

  10. #10
    Brunno Bassan
    Join Date
    Mar 2012
    Posts
    10
    Points
    0
    Answers Provided
    0


    0

    Default Re: Constrain InfoWindow to window size

    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.

  11. #11
    Andrew Bowne
    Join Date
    Oct 2009
    Posts
    289
    Points
    96
    Answers Provided
    19


    0

    Default Re: Constrain InfoWindow to window size

    Quote Originally Posted by brunno14 View Post
    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.
    Try setting a breakpoint in your MouseDown event and see if myinfowindow.isopen returns true. If it is true, then check the anchorpoint property and see if it falls within the extnent of your map.

  12. #12
    Brunno Bassan
    Join Date
    Mar 2012
    Posts
    10
    Points
    0
    Answers Provided
    0


    0

    Default Re: Constrain InfoWindow to window size

    Quote Originally Posted by andrewb View Post
    Try setting a breakpoint in your MouseDown event and see if myinfowindow.isopen returns true. If it is true, then check the anchorpoint property and see if it falls within the extnent of your map.
    OK.

    The IsOpen property returns true.

    Under the Anchor property, theres an Extent property with the following values:

    XMax -46.6654243469238
    XMin -46.6654243469238

    YMax -23.5543193817139
    YMin -23.5543193817139

    And the height and width properties are 0.0, is it normal?

    In the Extent property of myMap, there are the following values:

    XMax -5188689.952898005
    XMin -5195560.7625789493

    YMax -2697750.5551072815
    YMin -2701171.6058885315

    Height 3421.05078125
    Width 6870.8096809443086

    Is there anything wrong?

    Thanks

  13. #13
    Andrew Bowne
    Join Date
    Oct 2009
    Posts
    289
    Points
    96
    Answers Provided
    19


    1

    Default Re: Constrain InfoWindow to window size

    Quote Originally Posted by brunno14 View Post
    OK.

    The IsOpen property returns true.

    Under the Anchor property, theres an Extent property with the following values:

    XMax -46.6654243469238
    XMin -46.6654243469238

    YMax -23.5543193817139
    YMin -23.5543193817139

    And the height and width properties are 0.0, is it normal?

    In the Extent property of myMap, there are the following values:

    XMax -5188689.952898005
    XMin -5195560.7625789493

    YMax -2697750.5551072815
    YMin -2701171.6058885315

    Height 3421.05078125
    Width 6870.8096809443086

    Is there anything wrong?

    Thanks
    Based on your anchor point, it looks like you are somewhere in Brazil? But.... Is your map in a different spatial reference? The coords between the infowindow and the map extent don't seem to line up. The infowindow is opening, but somewhere else in the world! Make sure your map spatial ref is in

    WKID=4326


  14. #14
    Brunno Bassan
    Join Date
    Mar 2012
    Posts
    10
    Points
    0
    Answers Provided
    0


    0

    Default Re: Constrain InfoWindow to window size

    Quote Originally Posted by andrewb View Post
    Based on your anchor point, it looks like you are somewhere in Brazil? But.... Is your map in a different spatial reference? The coords between the infowindow and the map extent don't seem to line up. The infowindow is opening, but somewhere else in the world! Make sure your map spatial ref is in

    WKID=4326

    This seems to be the problem.

    I want to show the InfoWindow when user clicks in a graphic, that is an image... This graphic has a spatial reference different than the map...

    Code:
                                Graphic graphic = new Graphic();
                                graphic.Geometry = new MapPoint(X, Y, new SpatialReference(4326));
                                graphic.Symbol = myImage;
    the spatial ref of myMap is 102100...

    If I change the graphic's spatial ref to 102100, it appears in the middle of the ocean, but if I set to 4326 it appears in the right place...

    What should I do?

  15. #15
    Andrew Bowne
    Join Date
    Oct 2009
    Posts
    289
    Points
    96
    Answers Provided
    19


    1

    Default Re: Constrain InfoWindow to window size

    What is the source of your point-graphic data? If it's a feature class (shapefile, GeoDB, etc.) You can either project the source data from 4326 to 102100 or you can define 4326 as the spatial reference for your data frame and let ArcGIS project it on the fly.

    Alternatively, you can use a GeometryService to project your graphics coords from 4326 to 102100 right in ArcGIS Server. See: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Project
    Use the geometry of your graphic (in 4326) as the input, and use the output(in 102100) as the anchor point of your info window.




  16. #16
    Brunno Bassan
    Join Date
    Mar 2012
    Posts
    10
    Points
    0
    Answers Provided
    0


    0

    Default Re: Constrain InfoWindow to window size

    Quote Originally Posted by andrewb View Post
    What is the source of your point-graphic data? If it's a feature class (shapefile, GeoDB, etc.) You can either project the source data from 4326 to 102100 or you can define 4326 as the spatial reference for your data frame and let ArcGIS project it on the fly.

    Alternatively, you can use a GeometryService to project your graphics coords from 4326 to 102100 right in ArcGIS Server. See: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Project
    Use the geometry of your graphic (in 4326) as the input, and use the output(in 102100) as the anchor point of your info window.



    I'm using a GeometryService now and my graphics coords are in 102100, just like myMap...

    But no changes :/

    My InfoWindow doesnt show up...

    I dont know what I'm doing wrong :/

  17. #17
    Andrew Bowne
    Join Date
    Oct 2009
    Posts
    289
    Points
    96
    Answers Provided
    19


    0

    Default Re: Constrain InfoWindow to window size

    I was just looking back at some of the previous posts and I see you said you are trying to implement the infoWindow inside a userControl which is not the same page as your map. Have you tried to use it inside the same page as your map? Maybe see if you can get it to work in there. If you can, then maybe that'll give you some hints. I've never tried to implement the infoWindow on a page that's not the same as my map. I'm not sure why you would want to.

  18. #18
    Brunno Bassan
    Join Date
    Mar 2012
    Posts
    10
    Points
    0
    Answers Provided
    0


    0

    Default Re: Constrain InfoWindow to window size

    Quote Originally Posted by andrewb View Post
    I was just looking back at some of the previous posts and I see you said you are trying to implement the infoWindow inside a userControl which is not the same page as your map. Have you tried to use it inside the same page as your map? Maybe see if you can get it to work in there. If you can, then maybe that'll give you some hints. I've never tried to implement the infoWindow on a page that's not the same as my map. I'm not sure why you would want to.
    Let me explain why I need to implement the InfoWindow inside an UserControl....

    In my project, I have the MainPage, which contains the map and a toolbar... At this moment, theres no graphics on my map, just the map...

    When I click in an option in my toolbar, it shows a "pop up" with some options that I have to choose... The pop up is in a different page (another .xaml) than the map...

    In this pop up, there's a button, and when I click on it, it creates a GraphicsLayer, adds the new GraphicsLayer in the Layers property of my Map, create the graphics and add those graphics to the GraphicsLayer...

    This works fine...

    The problem is that I need to display an InfoWindow when user clicks in any of those graphics...

    Is there another way to do this?

  19. #19
    Andrew Bowne
    Join Date
    Oct 2009
    Posts
    289
    Points
    96
    Answers Provided
    19


    0

    Default Re: Constrain InfoWindow to window size

    You don't need to implement the infowindow inside your usercontrol, you can do it right on the same page as the map (the MainPage).

    Is your graphicslayer defined in your XAML or is it done via codebehind?

  20. #20
    Brunno Bassan
    Join Date
    Mar 2012
    Posts
    10
    Points
    0
    Answers Provided
    0


    0

    Default Re: Constrain InfoWindow to window size

    Quote Originally Posted by andrewb View Post
    You don't need to implement the infowindow inside your usercontrol, you can do it right on the same page as the map (the MainPage).

    Is your graphicslayer defined in your XAML or is it done via codebehind?
    via code-behind....

  21. #21
    Andrew Bowne
    Join Date
    Oct 2009
    Posts
    289
    Points
    96
    Answers Provided
    19


    0

    Default Re: Constrain InfoWindow to window size

    For ha-ha's, try changing from the MouseDown event to the MouseUp event.

  22. #22
    Brunno Bassan
    Join Date
    Mar 2012
    Posts
    10
    Points
    0
    Answers Provided
    0


    0

    Default Re: Constrain InfoWindow to window size

    No changes....

    I will try to move the InfoWindow to the map page and see if I can get this working...

    thanks for your help

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts