Popup window when onmouseover event

3080
5
11-10-2014 03:48 AM
AnatoliiTerentiev
Occasional Contributor III

Dear Gurus!

I am finding the best practice to solve next tasks.

1. Show in popup window some image. Image is in file,  attached   in some way to the feature .  In my case image files attached to records of x,y-table.

2. Show in popup window list of attribute values.

Pop-up window should appear at onmouseover event.

May be some reference to accelerate the process.

Thanks in advance!

Reply
0 Kudos
5 Replies
AnatoliiTerentiev
Occasional Contributor III

I read http://help.arcgis.com/en/webapi/wpf/help/index.html#/Adding_MapTips/01n70000001z000000/   , but there are a lot of x,y-tables.  It is desirable to look at the example of a realization MapTips in code.

P.S. I will try to see https://community.esri.com/thread/14745

Yes, last reference solved the problem. My xaml :

<UserControl x:Class="MapModule.Views.MapView"

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    

             xmlns:esri="http://schemas.esri.com/arcgis/client/2009"     

             >

    <Grid

        <esri:Map x:Name="Map" Background="White" WrapAround="true"

                                Extent="6095000,6810000,6900000,7258000" >

            <esri:ArcGISDynamicMapServiceLayer ID="BaseLayer"

                            Url="http://localhost:6080/ArcGIS/rest/services/streetRK/MapServer" />

            <esri:FeatureLayer   ID="routes_osm"

                            Url="http://localhost:6080/ArcGIS/rest/services/streetRK/MapServer/1">              

            </esri:FeatureLayer>

       </esri:Map>

    </Grid>

</UserControl>

And in code behind (similarly, it is possible to make in viewModel 😞

            FeatureLayer featureLayer = Map.Layers["routes_osm"] as FeatureLayer;

            featureLayer.MapTip = new LegendView();

Thank you dbroux-esristaff‌ again!!! Problem solved.

Reply
0 Kudos
AnatoliiTerentiev
Occasional Contributor III

One more refinement.

When constructing MapTip view I need to know the feature over which the mouse is. How it can be found ? Is there are some field In  feature layer which consist  the value of current feature under mouse or  it must be determined in  MouseEnter event?

Reply
0 Kudos
AnatoliiTerentiev
Occasional Contributor III

Next  variant suit me:

In xaml :

<esri:FeatureLayer    ID="bridges"                                 

      Url="http://localhost:6080/ArcGIS/rest/services/streetRK/MapServer/2"

         MouseEnter="FeatureLayer_MouseEnter" >

</esri:FeatureLayer>

In MapView.xaml.cs constructor I initialize MapTip:

            FeatureLayer featureLayer = Map.Layers["bridges"] as FeatureLayer;

            bridgeView = new BridgeView();

            featureLayer.MapTip = bridgeView;

And in the MouseEnter event handler :

private void FeatureLayer_MouseEnter(object sender, GraphicMouseEventArgs e)

{

      bridgeView.km.Text = e.Graphic.Attributes["km"].ToString();

      // And so on for other attributes, which used in MapTip PopUp View

}

Reply
0 Kudos
JenniferNery
Esri Regular Contributor

Hi Anatolii,

This SDK sample might interest you: ArcGIS API for Silverlight - Interactive Samples | ArcGIS for Developers  There is no need to subscribe to MouseEnter to get to the feature whose attributes will be displayed. Notice this sample has no code-behind but let me highlight the following code.

                    <esri:FeatureLayer.MapTip>                      

                        <Border CornerRadius="10" BorderBrush="#FF222957" BorderThickness="3" Margin="0,0,15,15">

                            <Border.Background>

                                <LinearGradientBrush EndPoint="1.038,1.136" StartPoint="0.015,0.188">

                                    <GradientStop Color="#FFD1DFF2"/>

                                    <GradientStop Color="#FF0088FF" Offset="0.946"/>

                                </LinearGradientBrush>

                            </Border.Background>

                            <Border.Effect>

                                <DropShadowEffect ShadowDepth="10" BlurRadius="14" Direction="300" />

                            </Border.Effect>

                            <StackPanel Margin="7">

                                <TextBlock Text="{Binding [CITY_NAME]}" FontWeight="Bold" Foreground="Black"  />

                                <StackPanel Orientation="Horizontal">

                                    <TextBlock Text="Population: " Foreground="Black" />

                                    <TextBlock Text="{Binding [POP1990]}" Foreground="Black" />

                                </StackPanel>

                            </StackPanel>

                        </Border>

                    </esri:FeatureLayer.MapTip>

                </esri:FeatureLayer>

MapTip can be constructed with any UIElement, its content can also be bound to an attribute. These bindings will resolve itself when your mouse enters a feature. {Binding [CITY_NAME]} assumes that CITY_NAME is a requested OutField.

AnatoliiTerentiev
Occasional Contributor III

Thank you very much, Jennifer!

I chose a different path, as I had to show my own form with parameters, Images, etc. In xaml :

        <esri:Map x:Name="Map" Background="White" WrapAround="true"

                                Extent="6095000,6810000,6900000,7258000" MouseMove="Map_MouseMove" MouseClick="Map_MouseClick">

            <esri:ArcGISDynamicMapServiceLayer ID="BaseLayer"

                            Url="http://localhost:6080/ArcGIS/rest/services/streetRK/MapServer" />

            <esri:FeatureLayer    ID="bridges"                                 

                            Url="http://localhost:6080/ArcGIS/rest/services/streetRK/MapServer/2"

                                  MouseEnter="FeatureLayer_MouseEnter" >

            </esri:FeatureLayer>

       </esri:Map>

        </esri:Map>

In constructor of code behind:

            bridgeView = new BridgeView();

            featureLayer.MapTip = bridgeView;

And

        private void FeatureLayer_MouseEnter(object sender, GraphicMouseEventArgs e)

        {

            try

            {

                bridgeView.km.Text = e.Graphic.Attributes["km"].ToString();

                       //processing other attributes to form  the view

            }

            catch (Exception){}

        }

Reply
0 Kudos