Select to view content in your preferred language

Feature layers don't re-project in map

2481
8
05-05-2011 11:43 AM
TimRourke
Emerging Contributor
We have been using the old street map layer from ArcGIS Online as a base map for some time in out web applications. We want to be able to use the basemap gallery widget to allow users to change the basemap using other layers from ArcGIS Online. We need to move to the base maps in the Web Mercator projection, but all our internal data is still stored in decimal degrees.

The API documentation says that non-tiled layers re-project on the fly, so I tried using the newer World Street Map layer as a base map and overlay our data layers on top as feature layers. They do not re-project, even though they display properly in ArcMap when loaded on top of the World Street Map layer. I have tried all available transformations for the re-projection in the map document, but the JavaScript API always displays our data using the decimal degree coordinates.

I then created new map services based on map documents that display the layers in the Web Mercator projection through transformation. Even these map services fail to be re-projected on the fly in the JavaScript API.

Has anyone else had this problem and resolved it? Or doesn't this feature work yet?
0 Kudos
8 Replies
derekswingley1
Deactivated User
I did some quick testing with an endpoint on one of the arcgis.com sample servers and it looks like it's working (at least via the REST API...).

Check out these two urls:
defalt, lat/long:  http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/...

projected to web mercator:  http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/...

What do the requests being sent to your server look like? Do they include the proper outSR parameter?
0 Kudos
TimRourke
Emerging Contributor
Derek,

I'm sorry but I don't see how the two forms at those URLs apply to this issue. My problem is that our feature layers in decimal degrees do not re-project when displayed in a map in Web Mercator. This is in a map application we built with the JavaScript API, not sending requests to services on ESRI services. The only ESRI service in our application is the base map. All other services are on our server and in our databases.

We are rolling out a version to production today so I don't have the time to set up and try the application again today. I'll take a look at it tomorrow and see what I can find in Fiddler about the spatial references and post it here.

Thanks
0 Kudos
derekswingley1
Deactivated User
Hi Tim,

The difference between the two is that the second includes a value for the outSR parameter which causes features to be projected to the specified SRID before being sent to the client.

When you create a feature layer with the JS API and add it to your map, requests are sent to your service for features. The JS API talks to the REST API so I was showing that the REST API is capable of what you're requesting. Unfortunately, the data behind the map service I was using seems to have changed so you can't see this in action. Instead, take a look at the attached screen shots.
0 Kudos
TimRourke
Emerging Contributor
I see what you meant now. I expected that the API would support it, however it doesn't seem to be the case. Is there an undocumented option I can set when creating a feature layer to tell it to draw in the map's spatial reference?
0 Kudos
TimRourke
Emerging Contributor
Derek,

Thanks for the suggestions. I took a look in Fiddler and it looks like one of our layers was being loaded before the base layer. Apparently the spatial reference was set by our layer instead of the base layer. I moved some code around to make sure of the layer load order and it works.

Thanks again.
0 Kudos
derekswingley1
Deactivated User
Glad you got it worked out!

Your map will use the spatial reference of the first layer you add (but I think you figured this out :)). If you're concerned about performance, I would suggest that you re-project your data being used in your feature layer(s) because it will result in faster response times from your services as your server won't need to re-project to web mercator on the fly.
0 Kudos
TimRourke
Emerging Contributor
I'd like to change our source data - mostly because I consider decimal degrees a poor choice for data storage - but it's not likely to happen soon. The data comes from several real-time systems and databases used by many business units in our company. We don't have the freedom to change things just for one app. Hopefully we'll be able to do it before ESRI changes map projections again. 🙂

Thanks again.
0 Kudos
derekswingley1
Deactivated User
Understood. Web mercator *should* be here to stay for a while...I don't see it going anywhere unless the big guys (Google, Bing) change things up (not likely, IMO).
0 Kudos