Select to view content in your preferred language

infowindow postion is not correct

1884
5
07-19-2011 01:23 PM
DanDong
Deactivated User
Hi guys,

I am using the infowindow tookiet in my application.
MyMap is located in Grid.row = 4 and grid.column = 1.
If I put the infowindow in the same row and column, it opens in a different location from what I just click on the map after I zooming in or out the map (See the picture, I click on the red point). [ATTACH]7845[/ATTACH]
 <esri:InfoWindow x:Name="ecocatParcelinfoWindow" Grid.Row="4" Grid.Column="1"
                         Padding="2"
                         CornerRadius="2"
                         Map="{Binding ElementName=MyMap}"
                         ContentTemplate="{StaticResource EcocatParcelInfoWindowTemplate}"/>


If I don't specify row and column in the infowindow, the position is correct, but it seems like only the first row is displayed..[ATTACH]7846[/ATTACH].

This is very weird...Any thoughts or ideas on how to fix it? Thanks advance!
0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
You do not need to provide Grid.Row/Column for InfoWindow, setting its Anchor property is sufficient. I tried updating this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#InfoWindowSimple by adding Rows and Columns to the Grid and placing map control in Grid.Row="1" Grid.Column="1". Without any other change in XAML and code-behind, I'm able to click on any location and show InfoWindow at the correct location.
0 Kudos
by Anonymous User
Not applicable
Original User: shirleydd

Thank you Jennifer! I did assign the Anchor property in the code-behind. The logic I used is to perform a identify task based on the mouseclick point. This identify task will work on three sublayers in one map services (19,20,21) and each of them needs different out fields. I give the mappoint to the anchor property(please see the red words). Did I miss something in my codes? Thank you!

In mymap_mouseclick event:
ShowMapTip(sender as Map, e.MapPoint);


in ShowMapTip function:
private void ShowMapTip(Map map, MapPoint pnt)
        {
            if (ecocatParcelinfoWindow.IsOpen)
                ecocatParcelinfoWindow.IsOpen = false;
            if (!ecocatParcelinfoWindow.IsOpen)
            {
                ecocatParcelinfoWindow.Content = null;
                IdentifyTask it = new IdentifyTask("http://rmms-dev.atlas.illinois.edu/ArcGIS/rest/services/wirt/MapServer");
                var p = new IdentifyParameters()
                {
                    MapExtent = MyMap.Extent,
                    Height = (int)MyMap.ActualHeight,
                    Width = (int)MyMap.ActualWidth,
                    SpatialReference = MyMap.SpatialReference,
                    Geometry = pnt
                };
                p.LayerOption = LayerOption.all;
                p.LayerIds.AddRange(new int[] { 19,20,21 });
                it.ExecuteCompleted +=new EventHandler<IdentifyEventArgs>(it_ExecuteCompleted);
                it.Failed += IdentifyTask_Failed;
                it.ExecuteAsync(p,pnt);
                           
             }
             ecocatParcelinfoWindow.IsOpen = !ecocatParcelinfoWindow.IsOpen;
        }


In identifytask_ExecuteCompleted event:
private void it_ExecuteCompleted(object sender, IdentifyEventArgs e)
        {
            if (e.IdentifyResults.Count == 0)
            {
                ecocatParcelinfoWindow.IsOpen = false;
                return;
            }

            List<string> outfield = new List<string>();
            if (e.IdentifyResults.ElementAt(0).LayerId == 19)
            {               
                outfield.Add("COMMON_NAM");
                outfield.Add("LAST_OBS_D");
                outfield.Add("EO_NUM");
            }

            else if (e.IdentifyResults.ElementAt(0).LayerId == 20)
            {
                outfield.Add("MA_NAME");
                outfield.Add("INPC_NUMBE");
            }

            else if (e.IdentifyResults.ElementAt(0).LayerId == 21)
            {
                outfield.Add("SITENAME");
                outfield.Add("NAINUM");
            }

            IDictionary<string, object> attributes = new Dictionary<string, object>();
            foreach (var item in e.IdentifyResults[0].Feature.Attributes)
                if (outfield.Contains(item.Key))
                    attributes.Add(item.Key, item.Value);
            MapPoint pnt = e.UserState as MapPoint;
            ecocatParcelinfoWindow.Anchor = pnt;  
            ecocatParcelinfoWindow.IsOpen = true;
            ecocatParcelinfoWindow.Content = attributes;
}
0 Kudos
deleted-user-ATjHIWsdQYmT
Deactivated User
Sounds similar to the same issue I experienced in this thread:  http://forums.arcgis.com/threads/23081-How-do-I-control-the-Infowindow-height?p=100995
0 Kudos
by Anonymous User
Not applicable
Original User: shirleydd

Sounds similar to the same issue I experienced in this thread:  http://forums.arcgis.com/threads/23081-How-do-I-control-the-Infowindow-height?p=100995


Yes, and I found your thread and use the method that you used to put a margin for the infowindow (Thank you :P). This seems solve the issue. But I am not sure this is a bug of the infowindow control or we still miss something in our codes....It is weird....

<esri:InfoWindow x:Name="ecocatParcelinfoWindow" Grid.Row="4" Margin="4,-115,0,0"                        
                         Padding="2"
                         CornerRadius="2"
                         Map="{Binding ElementName=MyMap}"
                         ContentTemplate="{StaticResource EcocatParcelInfoWindowTemplate}">
</esri:InfoWindow>
0 Kudos
komalagarwal
Deactivated User
I was facing similar issue and following imple solution has resolved my problem:

Problem: Anchor of infowindow was not positioned correctly in my window phone application
My Application layout: It has two rows and one column, first row Application header and Map in second row.
Solution:
Step1: Do not assign/set row/column to infowindow.
Step2: rowspan = 2

Setting rowspan has solved my problem.Hope it does for all.
0 Kudos