You can look at this help doc http://help.arcgis.com/en/arcgisserver/10.0/help/arcgis_server_dotnet_help/index.html#/Authoring_feature_services/009300000021000000/There is a section on defining symbology.
<esri:FeatureLayer ID="MyFeatureLayer" Renderer="{StaticResource PointSymbol}" ... />
<Grid.Resources> <esri:MarkerSymbol x:Key="SelectMarkerSymbol" > <esri:MarkerSymbol.ControlTemplate> <ControlTemplate> <Ellipse x:Name="Element" Width="15" Height="15" StrokeThickness="10" Stroke="Green" > <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="SelectionStates"> <VisualState x:Name="Unselected" /> <VisualState x:Name="Selected"> <Storyboard> <ColorAnimation Storyboard.TargetName="Element" Storyboard.TargetProperty="(Ellipse.Stroke).(SolidColorBrush.Color)" To="Cyan" Duration="00:00:0.25"/> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> </Ellipse> </ControlTemplate> </esri:MarkerSymbol.ControlTemplate> </esri:MarkerSymbol> <esri:SimpleRenderer x:Key="PointSymbol" Symbol="{StaticResource SelectMarkerSymbol}" /> </Grid.Resources>
Please take a look a the following SDK sample to get the whole idea:http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SelectGraphicsYou would need to set the FeatureSymbol property of your FeatureLayer to your custom symbol.
<Grid.Resources> <esriSymbols:SimpleMarkerSymbol x:Name="MyMarkerSymbol" Color="Red" Style="Diamond" Size="10" /> </Grid.Resources> <esri:Map x:Name="MyMap" Grid.RowSpan="2" > <esri:Map.Layers> <esri:ArcGISDynamicMapServiceLayer ID="SchoolSearch3" Url="http://198.182.104.173/ArcGIS/rest/services/SchoolSearch3/MapServer" VisibleLayers="0,1"/> <esri:FeatureLayer ID="MyFeatureLayer" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0" MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp" DisableClientCaching="True" Mode="OnDemand" OutFields="*" SelectionColor="Yellow" FeatureSymbol="{StaticResource MyMarkerSymbol}" > </esri:FeatureLayer> </esri:Map.Layers> </esri:Map>
You can do this by listening to the FeatureLayer_MouseLeftButtonUp event handler. Use the following code snippet to get the attribute collection of the Graphic object that has been clicked by the user: IDictionary<string, object> attributes = e.Graphic.Attributes;
IDictionary<string, object> attributes = e.Graphic.Attributes;
private void FeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs args) { FeatureLayer featureLayer = sender as FeatureLayer; for (int i = 0; i < featureLayer.SelectionCount; i++) featureLayer.SelectedGraphics.ToList().UnSelect(); args.Graphic.Select(); IDictionary<string, object> attributes = args.Graphic.Attributes; MessageBox.Show("This FID = " + attributes["FID"]) ; }
This is all you need for installing the API. http://help.arcgis.com/en/webapi/silverlight/help/Installation.htm
For Silverlight 4, you need API v2.0 and up. Yeah, check that the project references are correct and that they point to the proper file location. Once you have verified that your project has the proper version and files, maybe you just need to add imports statement:Imports ESRI.ArcGIS.Client
Imports ESRI.ArcGIS.Client
I think you will still get compile error because the FeatureLayer property would expect only FeatureLayer type. It is however, possible to create a FeatureLayer from a map service (maybe this is what you were doing). It is true that FeatureDataForm will show read-only fields if the FeatureLayer comes from a map service. You will not be allowed to edit, but you will be allowed to retrieve the feature ID, if this is part of your feature Attributes.
<esri:FeatureLayer ID="PointLayer" Url="http://198.182.104.173/ArcGIS/rest/services/Intersection_Test/MapServer/0" MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp" DisableClientCaching="True" Mode="OnDemand" SelectionColor="#FFFFFF00" OutFields="*" />
private void FeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs args)
If you are using FeatureDataForm, then you must be using FeatureLayer, because FeatureDataForm need to set its FeatureLayer property in order to display attributes.
Just to be clear: The Client APIs does not support working with Shapefiles. You will need to publish your data to ArcGIS Server first. After that, it doesn't' really matter how the data is stored as long as it is server out using ArcGIS Server. When you are at that point, you will be using a FeatureLayer as Jennifer was getting at.
I'm sorry I have more questions than answers. I wanted to know how you load shapefiles to your map? Does it have a corresponding .dbf that holds the attributes of the feature? I imagine that this is where you'd keep record of the object ID. How you create and save the object ID is important to know because it also dictates how you can retrieve them. You can use the graphic's Attributes to hold this information (http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Graphic~Attributes.html).It says that this is read-only property meaning you cannot create a new instance, but you can update the existing instance. You can do something like: Graphic g = new Graphic() { // set Geometry property from ShapeFile. } var objectId; // retrieve from DBF file (?) g.Attributes["objectid"] = objectId; // to save object id onto an attribute field var oid = g.Attributes["objectid']; // to retrieve the object id from an attribute field. Note that in this example, I just used "objectid" as my key for the field. You can name this as you wish but be mindful that the key you used to save is the same key you need to use to retrieve.Shapefile is actually an unfamiliar territory for me but I found some links that might be useful for your project.http://esrislcontrib.codeplex.com/http://forums.arcgis.com/threads/6425-Export-to-shapefile-other-formathttp://forums.arcgis.com/threads/13680-Download-Shapefiles-Similar-to-the-Extract-Service-in-ArcIMSOther developers are welcome to provide additional help 🙂
Graphic g = new Graphic() { // set Geometry property from ShapeFile. } var objectId; // retrieve from DBF file (?) g.Attributes["objectid"] = objectId; // to save object id onto an attribute field var oid = g.Attributes["objectid']; // to retrieve the object id from an attribute field.
<!--<esri:Map x:Name="MyMap" Grid.RowSpan="2" > <esri:Map.Layers> <esri:ArcGISDynamicMapServiceLayer ID="Intersections" Url="http://198.182.104.173/ArcGIS/rest/services/Intersection_Test/MapServer" /> </esri:Map.Layers> </esri:Map> -->
Kindly refer to this documentation: http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.FeatureService.FeatureLayerInfo~ObjectIdField.htmlIf LayerInfo is retrieved after the layer has initialized so be sure to check that layer.LayerInfo is not null. The following code retrieves the feature ID:var id = graphic.Attributes[layer.LayerInfo.ObjectIdField];
var id = graphic.Attributes[layer.LayerInfo.ObjectIdField];
Public ReadOnly Property ObjectIdField As String
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.