Imports System Imports System.Net Imports System.Windows Imports System.Windows.Controls Imports System.Windows.Documents Imports System.Windows.Ink Imports System.Windows.Input Imports System.Windows.Media Imports System.Windows.Media.Animation Imports System.Windows.Shapes Imports System.Collections.Generic Imports System.Linq Imports System.Text Imports System.Windows.Data Imports System.Windows.Media.Imaging Imports System.Windows.Navigation Imports System.Windows.Controls.Primitives Imports ESRI.ArcGIS.Client.Toolkit Namespace UserControls ' <summary> ' </summary> <TemplateVisualState(Name:="Collapsed", GroupName:="ViewStates"), _ TemplateVisualState(Name:="Expand", GroupName:="ViewStates"), _ TemplatePart(Name:="MaptTipImage", Type:=typeof(Image))> Public Class ExtendedMapTip Inherits MapTip ' <summary> ' </summary> #Region "Private fields" Private MaptTipImage As Image #End Region Public Sub New() DefaultStyleKey = GetType(ExtendedMapTip) End Sub #Region "Dependency Properties" ' <summary> ' Gets or sets a value indicating whether this control is expanded. ' </summary> ' <value> ' <c>true</c> if this instance is expanded; otherwise, <c>false</c>. ' </value> #End Region ' <summary> ' </summary> Public Overrides Sub OnApplyTemplate() MyBase.OnApplyTemplate() MaptTipImage = TryCast(Me.GetTemplateChild("MaptTipImage"), Image) If MaptTipImage IsNot Nothing Then AddHandler MaptTipImage.MouseLeftButtonUp, AddressOf Image_Click End If End Sub Public Sub Image_Click(sender As Object, e As MouseButtonEventArgs) Handles Me.MouseLeftButtonUp Try Dim MapTipImage As Image = TryCast(sender, Image) If MapTipImage Is DBNull.Value Then Return End If Dim Maptip As Grid = TryCast(MapTipImage.Parent, Grid) Me.HorizontalAlignment = HorizontalAlignment.Stretch Me.VerticalAlignment = VerticalAlignment.Stretch Catch generatedExceptionName As System.Exception End Try End Sub End Class End Namespace
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" xmlns:local="clr-namespace:MatrixWebMap.UserControls" xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" xmlns:converters="clr-namespace:MatrixWebMap.Converter" xmlns:esri="http://schemas.esri.com/arcgis/client/2009" xmlns:esriToolkit="clr-namespace:ESRI.ArcGIS.Client.Toolkit;assembly=ESRI.ArcGIS.Client.Toolkit" > <!-- Map Tip Style --> <Style x:Key="MapTipSkin" TargetType="esri:MapTip"> <Setter Property="Background" Value="#000000"/> <Setter Property="Foreground" Value="#FFFFFF"/> <Setter Property="Height" Value="Auto" /> <Setter Property="Opacity" Value="1"/> <Setter Property="BorderThickness" Value="2"/> <Setter Property="BorderBrush" Value="#FFFFFF"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="esri:MapTip"> <Grid x:Name="MapTipContents" MinWidth="50" Background="Black" Opacity="1" Width="Auto" Height="Auto"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Collapsed"> <Storyboard> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="MapTipData" Storyboard.TargetProperty="Height"> <SplineDoubleKeyFrame KeySpline="0.3,0 0,1" KeyTime="00:00:00.5" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="MapTipData" Storyboard.TargetProperty="Width"> <SplineDoubleKeyFrame KeySpline="0.3,0 0,1" KeyTime="00:00:00.5" Value="0"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="Expanded"> <Storyboard> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="MapTipData" Storyboard.TargetProperty="Height"> <SplineDoubleKeyFrame KeySpline="0.3,0 0,1" KeyTime="00:00:00.5" Value="240"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="MapTipData" Storyboard.TargetProperty="Width"> <SplineDoubleKeyFrame KeySpline="0.3,0 0,1" KeyTime="00:00:00.5" Value="360"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Grid x:Name="MapTip" MinWidth="50" Background="Black" Opacity="0.8" Width="Auto" Height="Auto"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="20"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Border Grid.RowSpan="2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5"/> <Polyline Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" Points="0,10 -10,-10 10,0"/> <ContentPresenter Margin="5,5,5,0" Content="{TemplateBinding Title}"/> <data:DataGrid x:Name="MapTipData" Height="0" Margin="5,5,5,5" Width="0" Grid.Column="0" Grid.Row="12" Foreground="White" RowBackground="#555555" AlternatingRowBackground="Black" AutoGenerateColumns="True" HeadersVisibility="None" ItemsSource="{TemplateBinding ItemsSource}" RowStyle="{StaticResource DataGridRowStyle}" /> </Grid> <Image x:Name="MapTipImage" Source="{Binding [FileLink]}" Margin="5,5,5,5" HorizontalAlignment="Center" Opacity="1" VerticalAlignment="Bottom" Width="Auto" Height="Auto" MaxHeight="{Binding ElementName=MapTipData, Path=Height}" MaxWidth="{Binding ElementName=MapTipData, Path=Width}" > <Image.Triggers> <EventTrigger RoutedEvent="Image.Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="MapTipContents" Storyboard.TargetProperty="Height" To="600"/> <DoubleAnimation Storyboard.TargetName="MapTipContents" Storyboard.TargetProperty="Width" To="800"/> </Storyboard> </BeginStoryboard> </EventTrigger> </Image.Triggers> </Image> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary>
Binding binding = newBinding(string.Format("[{0}]", NameField)); // binding.Source = g;
..... query.OutFields.Add("*"); query.ReturnGeometry = true; .......
void Layers_LayersInitialized(object sender, EventArgs args) { ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query() { Geometry = MyMap.Extent, OutSpatialReference = MyMap.SpatialReference }; query.OutFields.Add("*"); QueryTask queryTask = new QueryTask("http://gismaps.pagnet.org/ArcGIS/rest/services/Interactive_TIP_2011/MapServer/1"); queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted; queryTask.ExecuteAsync(query); } private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; MyMapTip.GraphicsLayer = graphicsLayer; if (featureSet != null && featureSet.Features.Count > 0) { foreach (Graphic feature in featureSet.Features) { feature.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(feature); } } }
void Map_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { var it = new IdentifyTask(_mapServiceLayer.Url); it.ExecuteCompleted += it_ExecuteCompleted; var ip = new IdentifyParameters { LayerOption = LayerOption.all, Height = (int)Map.RenderSize.Height, Width = (int)Map.RenderSize.Width, DPI = (int)Map.Resolution, Tolerance = 1, Geometry = Map.ScreenToMap(e.GetPosition(Map)), MapExtent = Map.Extent, SpatialReference = Map.SpatialReference }; it.ExecuteAsync(ip, null); IsBusy = true; } void it_ExecuteCompleted(object sender, IdentifyEventArgs e) { if (e.IdentifyResults.Count < 1) { IsBusy = false; ErrorMsg("No feature was found at that location"); return; } foreach (var res in e.IdentifyResults) { if (res.Feature == null || !res.Feature.Attributes.ContainsKey("OBJECTID")) continue; var objectid = (string) res.Feature.Attributes["OBJECTID"]; _featureLayer.Where = "OBJECTID = " + objectid; _featureLayer.Update(); return; } }
<esri2:SimpleMarkerSymbol x:Key="DefaultMarkerSymbol" Color="Aqua" Style="Circle" />
<esri:ArcGISDynamicMapServiceLayer ID="ConstructionProjects" Url="http://gismaps.pagnet.org/ArcGIS/rest/services/Interactive_TIP_2011/MapServer" VisibleLayers="1,2" > </esri:ArcGISDynamicMapServiceLayer> <esri:GraphicsLayer ID="MapTipGraphicsLayer"> <esri:GraphicsLayer.MapTip> <Border esri:GraphicsLayer.MapTipHideDelay="00:00:01.5" 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="#FF092959" Offset="0.946"/> </LinearGradientBrush> </Border.Background> <Border.Effect> <DropShadowEffect ShadowDepth="10" BlurRadius="14" Direction="300" /> </Border.Effect> <StackPanel Orientation="Vertical" Margin="20,15,20,15"> <StackPanel Orientation="Horizontal" Margin="0,0,0,6"> <TextBlock Text="TIP ID: " FontWeight="Bold" Foreground="#FF0F274E" FontSize="12" /> <!--<TextBlock Text="{Binding [TIP_ID]}" Foreground="#FFFFFFFF" FontSize="12" FontStyle="Italic" FontFamily="Portable User Interface" />--> </StackPanel> <StackPanel Orientation="Horizontal"> <TextBlock Text="Name: " FontWeight="Bold" Foreground="#FF0F274E" FontSize="12" /> <!--<TextBlock Text="{Binding [ST_NAME]}" Foreground="#FFFFFFFF" FontSize="12" FontStyle="Italic" FontFamily="Portable User Interface" />--> </StackPanel> </StackPanel> </Border> </esri:GraphicsLayer.MapTip> </esri:GraphicsLayer>
#region MapTip void MyMap_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "SpatialReference") { MapTipGraphicsLayerLoad(); MyMap.PropertyChanged -= MyMap_PropertyChanged; } } void MapTipGraphicsLayerLoad() { ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query() { Geometry = new ESRI.ArcGIS.Client.Geometry.Envelope(-180, 0, 0, 90), OutSpatialReference = MyMap.SpatialReference }; query.OutFields.Add("*"); QueryTask queryTask = new QueryTask("http://gismaps.pagnet.org/ArcGIS/rest/services/Interactive_TIP_2011/MapServer/1"); queryTask.ExecuteCompleted += MapTipGraphicsLayerQueryTask_ExecuteCompleted; queryTask.ExecuteAsync(query); } void MapTipGraphicsLayerQueryTask_Failed(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs queryArgs) { MessageBox.Show("Failed") ; } void MapTipGraphicsLayerQueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs queryArgs) { if (queryArgs.FeatureSet == null) return; FeatureSet resultFeatureSet = queryArgs.FeatureSet; ESRI.ArcGIS.Client.GraphicsLayer graphicsLayer = MyMap.Layers["MapTipGraphicsLayer"] as ESRI.ArcGIS.Client.GraphicsLayer; if (resultFeatureSet != null && resultFeatureSet.Features.Count > 0) { foreach (ESRI.ArcGIS.Client.Graphic graphicFeature in resultFeatureSet.Features) { graphicFeature.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(graphicFeature); } } } #endregion
Map PropertyChanged event is fired whenever a property of the map changes. In that specific sample, we are only concerned if the property that got changed is its SpatialReference. Dan is correct, when the first layer is added to your map, it should trigger SpatialReference property to change and since we unsubscribe to it after this, it would never be hit again. This is not the event that opens the maptip though.GraphicsLayer MapTip opens when mouse enters a graphic. You can listen to GraphicsLayer MouseEnter event, if you want but opening and closing the MapTip is handled by the API. When you say Map tip does not work.. what do you mean by that exactly? 😛 Map tip does not open or opens without content? Since you modified the services, you must have also updated the Binding statements since the attribute keys here are specific to the services in the sample. Also check that your graphics geometry and a symbol that is appropriate for this geometry type. Check also that if you used a symbol template, none of the elements here have IsHitTestVisible to false.
What is supposed to trigger the maptip?
That event is triggered when the first layer is initialized, which sets the map's spatial reference.
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.