xmlns:sys="clr-namespace:System;assembly=mscorlib"> <Grid x:Name="LayoutRoot" Background="White"> <ComboBox VerticalAlignment="Top" HorizontalAlignment="Center" SelectedIndex="0"> <ComboBox.Items> <!--<sys:Int32>1</sys:Int32>--> <sys:Int16>1</sys:Int16> </ComboBox.Items> </ComboBox> </Grid>
<esri2:SimpleMarkerSymbol x:Key="MySmallMarkerSymbol" Color="Green" Size="8" Style="Circle" /> <esri2:SimpleMarkerSymbol x:Key="MyMediumMarkerSymbol" Color="Blue" Size="8" Style="Circle" /> <esri2:SimpleMarkerSymbol x:Key="MyLargeMarkerSymbol" Color="Yellow" Size="8" Style="Circle" /> <esri:ClassBreaksRenderer x:Key="MyClassBreaksRenderer" Attribute="CONSTYEAR" > <esri:ClassBreaksRenderer.Classes> <esri:ClassBreakInfo MinimumValue="2011" MaximumValue="2011" Symbol="{StaticResource MySmallMarkerSymbol}" /> <esri:ClassBreakInfo MinimumValue="2012" MaximumValue="2012" Symbol="{StaticResource MyMediumMarkerSymbol}" /> <esri:ClassBreakInfo MinimumValue="2013" MaximumValue="2013" Symbol="{StaticResource MyLargeMarkerSymbol}" /> </esri:ClassBreaksRenderer.Classes> </esri:ClassBreaksRenderer>
CONSTYEAR (Type: esriFieldTypeSmallInteger, Alias: CONSTYEAR)
<esri:UniqueValueInfo Symbol="{StaticResource Year2011MarkerSymbol}"> <esri:UniqueValueInfo.Value> <sys:Int16>2011</sys:Int16> </esri:UniqueValueInfo.Value> </esri:UniqueValueInfo>
private void FeatureLayer_Initialized(object sender, System.EventArgs e) { UniqueValueRenderer uvr = (sender as FeatureLayer).Renderer as UniqueValueRenderer; foreach (var info in uvr.Infos) { if ((Int16)info.Value == (Int16)2011) info.Symbol = this.LayoutRoot.Resources["Year2011MarkerSymbol"] as Symbol; else if ((Int16)info.Value == (Int16)2012) info.Symbol = this.LayoutRoot.Resources["Year2012MarkerSymbol"] as Symbol; else if ((Int16)info.Value == (Int16)2013) info.Symbol = this.LayoutRoot.Resources["Year2013MarkerSymbol"] as Symbol; else if ((Int16)info.Value == (Int16)2014) info.Symbol = this.LayoutRoot.Resources["Year2014MarkerSymbol"] as Symbol; else if ((Int16)info.Value == (Int16)2015) info.Symbol = this.LayoutRoot.Resources["Year2015MarkerSymbol"] as Symbol; } }
<esri:FeatureLayer ID="ConstructionProjectsPoints" DisableClientCaching="False" Url="http://gismaps.pagnet.org/ArcGIS/rest/services/Interactive_TIP_2011/MapServer/0" Where="CONSTYEAR = 2011" OutFields="*" Renderer="{StaticResource MyUniqueValueRenderer}" > <esri:FeatureLayer.MapTip> <Border CornerRadius="10" BorderBrush="SaddleBrown" BorderThickness="3" Margin="0,0,15,15" Background="LightGray"> <StackPanel Margin="7"> <StackPanel Orientation="Horizontal"> <TextBlock Text="Location: " Foreground="Black" FontWeight="Bold"/> <TextBlock Text="{Binding [ST_NAME]}" Foreground="Black" /> </StackPanel> </StackPanel> </Border> </esri:FeatureLayer.MapTip> </esri:FeatureLayer>
Any insight into my custom renderer attempt?
You need to add OutFields="CONSTYEAR,ST_NAME" (or ="*")
<Grid.Resources> <esri2:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="#33FF0000" BorderBrush="Red" BorderThickness="2" /> <esri2:PictureMarkerSymbol x:Key="DefaultPictureSymbol" OffsetX="35" OffsetY="35" Source="component/Assets/images/identify.png" /> <esri2:SimpleMarkerSymbol x:Key="DefaultMarkerSymbol" Color="Aqua" Style="Circle" /> <esri2:SimpleMarkerSymbol x:Key="Year2011MarkerSymbol" Color="Green" Size="8" Style="Circle" /> <esri2:SimpleMarkerSymbol x:Key="Year2012MarkerSymbol" Color="Blue" Size="8" Style="Circle" /> <esri2:SimpleMarkerSymbol x:Key="Year2013MarkerSymbol" Color="Yellow" Size="8" Style="Circle" /> <esri2:SimpleMarkerSymbol x:Key="Year2014MarkerSymbol" Color="Orange" Size="8" Style="Circle" /> <esri2:SimpleMarkerSymbol x:Key="Year2015MarkerSymbol" Color="Red" Size="8" Style="Circle" /> <esri:UniqueValueRenderer x:Key="MyUniqueValueRenderer" Attribute="CONSTYEAR" > <esri:UniqueValueRenderer.Infos> <esri:UniqueValueInfo Value="2011" Symbol="{StaticResource Year2011MarkerSymbol}" /> <esri:UniqueValueInfo Value="2012" Symbol="{StaticResource Year2012MarkerSymbol}" /> <esri:UniqueValueInfo Value="2013" Symbol="{StaticResource Year2013MarkerSymbol}" /> <esri:UniqueValueInfo Value="2014" Symbol="{StaticResource Year2014MarkerSymbol}" /> <esri:UniqueValueInfo Value="2015" Symbol="{StaticResource Year2015MarkerSymbol}" /> </esri:UniqueValueRenderer.Infos> </esri:UniqueValueRenderer>
<esri:FeatureLayer ID="ConstructionProjectsPoints" DisableClientCaching="False" Url="http://gismaps.pagnet.org/ArcGIS/rest/services/Interactive_TIP_20111/MapServer/0" Renderer="{StaticResource MyUniqueValueRenderer}" Where="CONSTYEAR = 2011" > <esri:FeatureLayer.MapTip> <Border CornerRadius="10" BorderBrush="SaddleBrown" BorderThickness="3" Margin="0,0,15,15" Background="LightGray"> <StackPanel Margin="7"> <StackPanel Orientation="Horizontal"> <TextBlock Text="Location: " Foreground="Black" FontWeight="Bold"/> <TextBlock Text="{Binding [ST_NAME]}" Foreground="Black" /> </StackPanel> </StackPanel> </Border> </esri:FeatureLayer.MapTip> </esri:FeatureLayer>
<esri:FeatureLayer ID="ConstructionProjectsLines" DisableClientCaching="False" Url="http://gismaps.pagnet.org/ArcGIS/rest/services/Interactive_TIP_20111/MapServer/1" > <esri:FeatureLayer.MapTip> <Border CornerRadius="10" BorderBrush="SaddleBrown" BorderThickness="3" Margin="0,0,15,15" Background="LightGray"> <StackPanel Margin="7"> <StackPanel Orientation="Horizontal"> <TextBlock Text="Location: " Foreground="Black" FontWeight="Bold"/> <TextBlock Text="{Binding [ST_NAME]}" Foreground="Black" /> </StackPanel> </StackPanel> </Border> </esri:FeatureLayer.MapTip> </esri:FeatureLayer> <esri:FeatureLayer ID="ConstructionProjectsPoints" DisableClientCaching="False" Url="http://gismaps.pagnet.org/ArcGIS/rest/services/Interactive_TIP_20111/MapServer/0" > <esri:FeatureLayer.MapTip> <Border CornerRadius="10" BorderBrush="SaddleBrown" BorderThickness="3" Margin="0,0,15,15" Background="LightGray"> <StackPanel Margin="7"> <StackPanel Orientation="Horizontal"> <TextBlock Text="Location: " Foreground="Black" FontWeight="Bold"/> <TextBlock Text="{Binding [ST_NAME]}" Foreground="Black" /> </StackPanel> </StackPanel> </Border> </esri:FeatureLayer.MapTip> </esri:FeatureLayer>
Each of these layers is defined with a single symbol in the service. (This seems to be a requirement to get the map tip to work.)
would it be best to create a FeatureLayer for each year, or can all 5 years be presented in a single FeatureLayer
Is there a sample around that shows how to render different symbols within a layer based on the attribute data?
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.