Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to display information in an InfoWindow when the user clicks on a point on a map. I have the content in the InfoWindow and it is popping up. The only problem is the InfoWindow pops up no matter where you click on the map and it just displays the information from the previous Grapic point clicked. Any help would be appreciated. Here is my code:

XAML:

 <esri:Map x:Name="MyMap" Background="#FFE3E3E3" WrapAround="True" MouseClick="MyMap_MouseClick" MouseRightButtonDown="MyMap_MouseRightButtonDown" Extent="-9834972.92753924,4441899.425293319,-9833977.88119163, 4442762.485358352">
                <esri:Map.Layers>

                    <esri:ArcGISTiledMapServiceLayer ID="MyLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
                    <esri:ArcGISDynamicMapServiceLayer ID="Calvert_City" Url="http://localhost:6080/arcgis/rest/services/CalvertCity_Test_2/MapServer"/>
                    <esri:FeatureLayer ID="Water_Valves" Url="http://localhost:6080/arcgis/rest/services/CalvertCity_Test_2/MapServer/0" Renderer="{StaticResource MySimpleRenderer}"
                                                  OutFields="WVAL_ID,SIZE,WVAL_USE,WVAL_TYPE,OPENS,TURNS" MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp"/>
                </esri:Map.Layers> 
            </esri:Map>
            <esri:InfoWindow x:Name="MyInfoWindow"
                             Padding="2"
                             CornerRadius="20"
                             Background="{StaticResource PanelGradient}"
                             Map="{Binding ElementName=MyMap}"
                             ContentTemplate="{StaticResource MyFeatureLayerInfoWindowTemplate}">                
            </esri:InfoWindow>

C#:

MapPoint lastPoint = null;

        private void FeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs e)
        {
            FeatureLayer flayer = sender as FeatureLayer;

            MapPoint clickpoint = MyMap.ScreenToMap(e.GetPosition(MyMap));

            if (clickpoint != lastPoint)
            {
                MyInfoWindow.Anchor = clickpoint;
                MyInfoWindow.Content = e.Graphic.Attributes;
                MyInfoWindow.IsOpen = true;
                lastPoint = clickpoint;
            }
        }

If you need any more information, just let me know. Thanks.

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.