Zoom to

2761
15
01-03-2011 08:15 AM
JayKappy
Occasional Contributor
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.

I am no running into issues with an example from ESRI Silverlight API...
            ' 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)


This code is sort of working....
It highlights the selected feature and does a zoom.
BUT i have no idea where the zoom is to?  Its moving to an entrire differnet location than the selected feature should be.  It is selecting a Parcel...but moves to another location where the parcels are not....Could this be an issues with the two different coordinate systems...(between the ESRI data and mine).

Any thoughts?  Is there a way I can specify the projection info on the Zoom ?????

Thanks
0 Kudos
15 Replies
JayKappy
Occasional Contributor
You have just to initialize the spatialreference of your identify parameters to the spatial reference of your map. 
  
Something like: 
identifyParams.SpatialReference = MyMap.SpatialReference


I try this and it does not like the last line: NOT doign an Identify
Error:
Value of Type ESRI.ArcGIS.Client.Tasks.IdentifyParameters cannot be converted to ESRI.ArcGIS.Client.Tasks.Query

        ' 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)


I then tried to change
Dim identifyParamsParcels As ESRI.ArcGIS.Client.Tasks.IdentifyParameters = New IdentifyParameters() With {.SpatialReference = MyMap.SpatialReference}
to
Dim identifyParamsParcels As ESRI.ArcGIS.Client.Tasks.QueryTasks= New QueryTasks() With {.SpatialReference = MyMap.SpatialReference}

But it did not lke spatial reference
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Sorry I gave you the code for 'Identify' instead 'Query'.

Query version:
query.ReturnGeometry = true;
query.OutSpatialReference = MyMap.SpatialReference;
0 Kudos
JayKappy
Occasional Contributor
Sorry I gave you the code for 'Identify' instead 'Query'. 
  
Query version: 
query.ReturnGeometry = true;
query.OutSpatialReference = MyMap.SpatialReference;


THANK YOU dbroux......and the rest of you for your thoughts....was getting really confused because I felt I was being lead in 3 different directions...but learn a bunch along the way...

At least I know know hwo to control the idetifiy and Query outputs...

great to have a job that we can learn and grow everyday...

Thanks all for your help and patience....the above solved all my issues....
I forgot about the code that was calling the sub to perform the query....now the wiser....


THANKS AGAIN EVERYONE......VERY VERY APPRECIATED....

    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
0 Kudos
JayKappy
Occasional Contributor
esrijay
J Lennon

Just to note..See last entry.....I placed all my ESRI tile services back in my map with differetn projections and by setting the spatial reference of my query to the Maps Spatial reference everything works....SO you can have multiple spatial refernced Tile Layers in your app.....



Jay,

Trust me they are cached/tiled services in different projections...Not Clean.  Drop 10200 the service
http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer.

In your screenshots your starting coords are coods similar to: -115.55 and 26
These coords look like Web Mecator 4326 - Check out the rest end point of http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer
Your see the extents are
Intial Extent:

XMin: -301.639333008995
YMin: -226.229499756746
XMax: 301.639333008995
YMax: 226.229499756746
Spatial Reference: 4326

Full Extent:

XMin: -179.99999
YMin: -89.99999
XMax: 179.99999
YMax: 89.99999
Spatial Reference: 4326



NOW Lookk at the Coords after your Zoom:  They are like 5641362.218 and -10407985.655 - these look like Web Mecartor 102100 coords
Now take a look at this endpoint http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer

Notice the extent are very similar:

Intial Extent:

XMin: -20037507.0671618
YMin: -22882589.2065154
XMax: 20037507.0671618
YMax: 22882589.2065155
Spatial Reference: 102100 (3857)

Full Extent:

XMin: -20037507.0671618
YMin: -19971868.8804086
XMax: 20037507.0671618
YMax: 19971868.8804086
Spatial 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/MapServer
Rebuild and test.

J
0 Kudos
dotMorten_esri
Esri Notable Contributor
You cannot mix tiled layers that have different spatial references (I know for a fact - I wrote the line of code that prevents it :-). So if it is indeed working for you, make sure you are not using ArcGISDynamicMapserviceLayer instead of ArcGISTiledMapServiceLayer. If you use the dynamic type and point it to a cached/tiled service, the service will be able to reproject, but you won't get the performance benefit of a cached/tiled service.

Basically a tiled service can act both as a tiled and dynamic service, where a dynamic service can only act as a dynamic service. It's up to the client app to choose the 'right' layer type to use with the service. Use the tiled type if you can, but use dynamic if you need to reproject on the fly or if the service isn't cached/tiled.
0 Kudos
JayKappy
Occasional Contributor
Gotcha....thanks for the info....still learning here...not trying to tell you whats what here...obviosly I am the one that does not know as I am asking the questions...

I really appreciate all your help....thanks again
0 Kudos