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)
Jay,Trust me they are cached/tiled services in different projections...Not Clean. Drop 10200 the servicehttp://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer. In your screenshots your starting coords are coods similar to: -115.55 and 26These coords look like Web Mecator 4326 - Check out the rest end point of http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServerYour see the extents are Intial Extent: XMin: -301.639333008995YMin: -226.229499756746XMax: 301.639333008995YMax: 226.229499756746Spatial Reference: 4326Full Extent: XMin: -179.99999YMin: -89.99999XMax: 179.99999YMax: 89.99999Spatial Reference: 4326NOW Lookk at the Coords after your Zoom: They are like 5641362.218 and -10407985.655 - these look like Web Mecartor 102100 coordsNow take a look at this endpoint http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServerNotice the extent are very similar:Intial Extent: XMin: -20037507.0671618YMin: -22882589.2065154XMax: 20037507.0671618YMax: 22882589.2065155Spatial Reference: 102100 (3857)Full Extent: XMin: -20037507.0671618YMin: -19971868.8804086XMax: 20037507.0671618YMax: 19971868.8804086Spatial Reference: 102100 (3857)From my understanding there is no way you can project these two services at the same time and it is very bad practice to have 2 different projected cached services!Just for humor drop the http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServerRebuild and test.J
Sorry I gave you the code for 'Identify' instead 'Query'. Query version: query.ReturnGeometry = true; query.OutSpatialReference = MyMap.SpatialReference;
query.ReturnGeometry = true; query.OutSpatialReference = MyMap.SpatialReference;
Private Sub QueryComboBox_SelectionChangedSearch(ByVal sender As Object, ByVal e As SelectionChangedEventArgs) If QueryComboBox.SelectedItem.ToString().Contains("Select...") Then Return End If Dim queryTask As New QueryTask("http://gis.org/arcgis/rest/services/MG_Test_WGS84/MapServer/8") AddHandler queryTask.ExecuteCompleted, AddressOf QueryTask_ExecuteCompletedSearch AddHandler queryTask.Failed, AddressOf QueryTask_FailedSearch Dim query As New ESRI.ArcGIS.Client.Tasks.Query() query.OutFields.Add("*") query.Text = QueryComboBox.SelectedItem.ToString() query.ReturnGeometry = True query.OutSpatialReference = MyMap.SpatialReference queryTask.ExecuteAsync(query) End Sub
You have just to initialize the spatialreference of your identify parameters to the spatial reference of your map. Something like: identifyParams.SpatialReference = MyMap.SpatialReference
identifyParams.SpatialReference = MyMap.SpatialReference
' QUERY NUMBER 2 Dim identifyParamsParcels As ESRI.ArcGIS.Client.Tasks.IdentifyParameters = New IdentifyParameters() With {.SpatialReference = MyMap.SpatialReference} identifyParamsParcels.LayerIds.Add(8) Dim queryTask62 As New QueryTask("http://gis.org/arcgis/rest/services/MG_Test_WGS84/MapServer/8") AddHandler queryTask.ExecuteCompleted, AddressOf QueryTask_ExecuteCompletedSearch AddHandler queryTask.Failed, AddressOf QueryTask_FailedSearch queryTask.ExecuteAsync(identifyParamsParcels)
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
I have my app and have added a bunch of layers from ESRI 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"/> 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....
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
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.
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.