Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer"/> Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"/> Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" /> Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/> Url="http://servicer.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_MedianIncome_US_2D/MapServer"/>
' Zoom to selected feature (define expand percentage) Dim selectedFeatureExtent As ESRI.ArcGIS.Client.Geometry.Envelope = selectedFeature.Geometry.Extent Dim expandPercentage As Double = 230 Dim widthExpand As Double = selectedFeatureExtent.Width * (expandPercentage / 50) Dim heightExpand As Double = selectedFeatureExtent.He ight * (expandPercentage / 50) Dim displayExtent As New ESRI.ArcGIS.Client.Geometry.Envelope(selectedFeatureExtent.XMin - (widthExpand / 2), selectedFeatureExtent.YMin - (heightExpand / 2), selectedFeatureExtent.XMax + (widthExpand / 2), selectedFeatureExtent.YMax + (heightExpand / 2)) MyMap.ZoomTo(displayExtent)
The Client API does not automatically do reprojection. You would have to call the GeometryService.Project method to reproject you features to the spatial reference of the map, prior to calling zoom, or up front retrieve your features in the correct spatial reference.
Error 3 Argument not specified for parameter 'sender' of 'Private Sub GeometryService_ProjectCompleted(sender As Object, args As ESRI.ArcGIS.Client.Tasks.GraphicsEventArgs)'. C:\Users\jkapalczynski\Documents\Visual Studio 2010\Projects\gislis2010_live\MainPage.xaml.vb 1388 45 gislis2010_live Error 2 Argument not specified for parameter 'args' of 'Private Sub GeometryService_ProjectCompleted(sender As Object, args As ESRI.ArcGIS.Client.Tasks.GraphicsEventArgs)'. C:\Users\jkapalczynski\Documents\Visual Studio 2010\Projects\gislis2010_live\MainPage.xaml.vb 1388 45 gislis2010_live Error 1 'Public Event ProjectCompleted(sender As Object, e As ESRI.ArcGIS.Client.Tasks.GraphicsEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event. C:\Users\jkapalczynski\Documents\Visual Studio 2010\Projects\gislis2010_live\MainPage.xaml.vb 1388 9 gislis2010_live Error 4 'Public Event AreasAndLengthsCompleted(sender As Object, e As ESRI.ArcGIS.Client.Tasks.AreasAndLengthsEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event. C:\Users\jkapalczynski\Documents\Visual Studio 2010\Projects\gislis2010_live\MainPage.xaml.vb 1507 9 gislis2010_live Error 5 'GeometryService_AreasAndLengthsCompleted' is not declared. It may be inaccessible due to its protection level. C:\Users\jkapalczynski\Documents\Visual Studio 2010\Projects\gislis2010_live\MainPage.xaml.vb 1507 53 gislis2010_live
Private Sub QueryTask_ExecuteCompletedSearch(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.Tasks.QueryEventArgs) Dim featureSet As FeatureSet = args.FeatureSet ' If initial query to populate states combobox If (TryCast(args.UserState, String)) = "initial" Then ' Just show on initial load QueryComboBox.Items.Add("Select...") For Each graphic As Graphic In args.FeatureSet.Features QueryComboBox.Items.Add(graphic.Attributes("PID").ToString()) Next graphic QueryComboBox.SelectedIndex = 0 Return End If ' Remove the first entry if "Select..." If QueryComboBox.Items(0).ToString().Contains("Select...") Then QueryComboBox.Items.RemoveAt(0) End If ' If an item has been selected ' THIS IS WHERE I AM TRYING TO CHANGE THE GEOMETRY CALLING THE Private Sub GeometryService_ProjectCompleted Dim geometryService As New GeometryService("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" & "Geometry/GeometryServer") geometryService.ProjectCompleted += GeometryService_ProjectCompleted() Dim graphicsLayer As GraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayerSearch"), GraphicsLayer) geometryService.ProjectAsync(graphicsLayer.ToList(), New SpatialReference(4326)) graphicsLayer.ClearGraphics() If featureSet IsNot Nothing AndAlso featureSet.Features.Count > 0 Then ' Show selected feature attributes in DataGrid Dim selectedFeature As Graphic = featureSet.Features(0) IdentifyDetailsDataGrid5.DataContext = selectedFeature.Attributes ' Hightlight selected feature selectedFeature.Symbol = TryCast(LayoutRoot.Resources("ResultsFillSymbol"), ESRI.ArcGIS.Client.Symbols.Symbol) graphicsLayer.Graphics.Add(selectedFeature) Dim selectedFeatureExtent As ESRI.ArcGIS.Client.Geometry.Envelope = selectedFeature.Geometry.Extent Dim expandPercentage As Double = 230 Dim widthExpand As Double = selectedFeatureExtent.Width * (expandPercentage / 100) Dim heightExpand As Double = selectedFeatureExtent.Height * (expandPercentage / 100) Dim displayExtent As New ESRI.ArcGIS.Client.Geometry.Envelope(selectedFeatureExtent.XMin - (widthExpand / 2), selectedFeatureExtent.YMin - (heightExpand / 2), selectedFeatureExtent.XMax + (widthExpand / 2), selectedFeatureExtent.YMax + (heightExpand / 2)) MyMap.ZoomTo(displayExtent) If IdentifyResultsPanel5.Visibility = Visibility.Collapsed Then IdentifyResultsPanel5.Visibility = Visibility.Visible IdentifyGrid5.Height = Double.NaN IdentifyGrid5.UpdateLayout() End If Else IdentifyResultsPanel5.DataContext = Nothing IdentifyResultsPanel5.Visibility = Visibility.Collapsed IdentifyGrid5.Height = Double.NaN IdentifyGrid5.UpdateLayout() End If End Sub
Private Sub GeometryService_ProjectCompleted(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.Tasks.GraphicsEventArgs)
Dim geometryService As New GeometryService("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" & "Geometry/GeometryServer")
geometryService.AreasAndLengthsCompleted += GeometryService_AreasAndLengthsCompleted
geometryService.AreasAndLengthsAsync(args.Results)
End Sub
I have my app and have added a bunch of layers from ESRIUrl="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer"/> Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"/> Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" /> Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/> Url="http://servicer.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_MedianIncome_US_2D/MapServer"/>
They draw great...adn then I added a bunch of my own layers on top of those. These are in a DIFFERENT projection that much I know. But they still display fine.
This is my Map Grid...Spatial Reference 4326....
when you query these layers, just make sure you set the OutputSpatialReference on the query to be the same as Map.SpatialReference. That way you will always get features back in an SR that matches the map, and you won't have to mess with reprojecting the features again later.
<esri:Map x:Name="MyMap" MouseClick="QueryPoint_MouseClick" TimeExtent="{Binding ElementName=MyTimeSlider, Path=Value}"> <esri:Map.Extent> <esri:Envelope XMin="-90.99999" YMin="25.99999" XMax="-95.99999" YMax="50.99999" > <esri:Envelope.SpatialReference> <esri:SpatialReference WKID="4326"/> </esri:Envelope.SpatialReference> </esri:Envelope> </esri:Map.Extent> <esri:Map.Layers> <esri:ArcGISDynamicMapServiceLayer ID="State,City,Highway" Opacity="0.6" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer"/> <!-- MAPLE GROVE LAYERS--> <esri:ArcGISDynamicMapServiceLayer ID="MG_Streets" Visible="False" Url="http://gis.org/arcgis/rest/services/MG_Test/MapServer" Initialized="Streets_Initialized"/> <esri:ArcGISDynamicMapServiceLayer ID="MG_Parcels" Url="http://gis.org/arcgis/rest/services/MG_Test_WGS84/MapServer" Initialized="Parcels_Initialized"/> <esri:GraphicsLayer ID="MyGraphicsLayerSearch" /> <esri:GraphicsLayer ID="MyLayer" /> </esri:Map.Layers> </esri:Map>
Private Sub QueryTask_ExecuteCompletedSearch(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.Tasks.QueryEventArgs) Dim featureSet As FeatureSet = args.FeatureSet ' If initial query to populate states combobox If (TryCast(args.UserState, String)) = "initial" Then ' Just show on initial load QueryComboBox.Items.Add("Select...") For Each graphic As Graphic In args.FeatureSet.Features QueryComboBox.Items.Add(graphic.Attributes("PID").ToString()) Next graphic QueryComboBox.SelectedIndex = 0 Return End If ' Remove the first entry if "Select..." If QueryComboBox.Items(0).ToString().Contains("Select...") Then QueryComboBox.Items.RemoveAt(0) End If ' If an item has been selected Dim graphicsLayer As GraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayerSearch"), GraphicsLayer) Dim geometryService As New GeometryService("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" & "Geometry/GeometryServer") AddHandler geometryService.ProjectCompleted, AddressOf GeometryService_ProjectCompleted Dim graphicsLayer As GraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayerSearch"), GraphicsLayer) geometryService.ProjectAsync(graphicsLayer.ToList(), New SpatialReference(4326)) graphicsLayer.ClearGraphics() If featureSet IsNot Nothing AndAlso featureSet.Features.Count > 0 Then ' Show selected feature attributes in DataGrid Dim selectedFeature As Graphic = featureSet.Features(0) IdentifyDetailsDataGrid5.DataContext = selectedFeature.Attributes ' Hightlight selected feature selectedFeature.Symbol = TryCast(LayoutRoot.Resources("ResultsFillSymbol"), ESRI.ArcGIS.Client.Symbols.Symbol) graphicsLayer.Graphics.Add(selectedFeature) ' Zoom to selected feature (define expand percentage) Dim selectedFeatureExtent As ESRI.ArcGIS.Client.Geometry.Envelope = selectedFeature.Geometry.Extent Dim expandPercentage As Double = 230 Dim widthExpand As Double = selectedFeatureExtent.Width * (expandPercentage / 100) Dim heightExpand As Double = selectedFeatureExtent.Height * (expandPercentage / 100) Dim displayExtent As New ESRI.ArcGIS.Client.Geometry.Envelope(selectedFeatureExtent.XMin - (widthExpand / 2), selectedFeatureExtent.YMin - (heightExpand / 2), selectedFeatureExtent.XMax + (widthExpand / 2), selectedFeatureExtent.YMax + (heightExpand / 2)) MyMap.ZoomTo(displayExtent) End Sub Private Sub GeometryService_ProjectCompleted(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.Tasks.GraphicsEventArgs) Dim geometryService As New GeometryService("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" & "Geometry/GeometryServer") AddHandler geometryService.AreasAndLengthsCompleted, AddressOf GeometryService_AreasAndLengthsCompleted geometryService.AreasAndLengthsAsync(args.Results) End Sub Private Sub GeometryService_AreasAndLengthsCompleted(ByVal sender As Object, ByVal args As AreasAndLengthsEventArgs) Dim results As String = "" For i As Integer = 0 To args.Results.Areas.Count - 1 results += String.Format("Graphic {0}: Area = {1}, Perimeter = {2}" & vbLf, i, args.Results.Areas(i), args.Results.Lengths(i)) Next End Sub
identifyParams.SpatialReference = MyMap.SpatialReference