Change Map Projection on the Fly

2620
5
Jump to solution
03-19-2013 03:55 PM
PremRadhakrishnan
New Contributor III
I have a tiled service and a dynamic service in one projection (wkid 2245 ) . I want to bring bring in a portal basemap in a different projection  ( web mercator - 102100 ) and replace the existing basemap and have the dynamic service be reprojected on the fly . I am trying to accomplish this by switching the map projection on the fly.

The flex viewer adds the portal layers but does not take into account basemaps in a different projection that have already been added to the map.

I read through the forums and changing the map extent seems to be the common suggested solution but its not working for me This is what I have tried

map.initialExtent = new Extent(-9693000, 4713900, -9551000, 4775800, new SpatialReference(102100);
map.extent = new Extent(-9693000, 4713900, -9551000, 4775800, new SpatialReference(102100);
trace(map.spatialReference.wkid);

All that this is doing is changing the extent to the new extent in the existing map projection. The spatial reference itself is not being changed. The trace gives the same 2245 result . Am I missing something completely obvious here or is this not possible. I am not worried about any graphics layers or anything like that at this time just getting the basemap to switch would be the first step.

Thanks in advance.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Premkrishnan,

   A little searching in the forum would reveal this thread:

http://forums.arcgis.com/threads/69878-Solution-switching-between-tiled-services-in-different-projec....

and several more.

View solution in original post

0 Kudos
5 Replies
RhettZufelt
MVP Frequent Contributor
Premkrishnan,

Since the portal basemaps are tiled, you must either set your wkid in your map tag to the mercator (WKID="102100") OR, make sure it loads that basemap first (which will set the wkid of the map).
This would set the wkid of you flexviewer to 102100.  Now, as long as the data your service(s) include have the projection defined, you can load them as dynamic, and it will automatically project them to the correct location on the fly.

Of course, you will not be able to load "your" tiled service unless you load as dynamic OR, reproject to 102100 and re-build your cache with the new wkid.

Hope this helps,

R_
0 Kudos
PremRadhakrishnan
New Contributor III
Thanks it basically confirms what I already was afraid of , there is no way to change the map projection once its set. If you load a basemap in one projection then want to change the map projection and load another basemap in a different projection there is just no way.

This seems really counter intuitive, coz you need one map per projection of the different basemaps you have to display a single dynamic service on top of different base maps in different projections.

I am looking for a method where the map itself doesnt have to be changed ( reinitialized ) to load a basemap in a different projection, rather to remove one basemap change the projection and add a different one into the same map instance.

I will wait for a few more replies and if nothing comes in will mark this as closed.

Premkrishnan,

Since the portal basemaps are tiled, you must either set your wkid in your map tag to the mercator (WKID="102100") OR, make sure it loads that basemap first (which will set the wkid of the map).
This would set the wkid of you flexviewer to 102100.  Now, as long as the data your service(s) include have the projection defined, you can load them as dynamic, and it will automatically project them to the correct location on the fly.

Of course, you will not be able to load "your" tiled service unless you load as dynamic OR, reproject to 102100 and re-build your cache with the new wkid.

Hope this helps,

R_
0 Kudos
RhettZufelt
MVP Frequent Contributor
Thanks it basically confirms what I already was afraid of , there is no way to change the map projection once its set. If you load a basemap in one projection then want to change the map projection and load another basemap in a different projection there is just no way. 

This seems really counter intuitive, coz you need one map per projection of the different basemaps you have to display a single dynamic service on top of different base maps in different projections.


Well, I think for the most part, people are either consuming public services, or they have thier own server so are running their basemaps using a single wkid. 
Most ESRI basemaps are in mercator, and not very detailed.  All my data is in State Plane meters so I also have basemaps in State Plane, meters so there is no issue.  (well, almost, I do occationally load an ESRI basemap as dynamic so it overlays on StatePlane)

Of course, the best practice is to make sure all data loaded is in the same spatial reference and not mix basemaps.

If you really want to use ESRI basemap(s) AND your basemaps, you could convert your basemap to mercator and rebuild the tiles, then both will be available in MapSwitcher and should display properly and your dynamic services will overlay as well. (Keep in mind though, if you convert your basemap to mercator and tile it, you will need to match the ESRI tiling scheme for it to work properly.)

Other option, load the ESRI basemap first (or set wkid to mercator), then load your basemap as dynamic.  Will then both be available in MapSwitcher and will overlay properly.  Could do it the other way (load ESRI service as dynamic), but due to size and server load, the ESRI basemaps take some time to load when loading as dynamic and I'd bet yours will load faster.

Hope you find this usefull,

R_
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Premkrishnan,

   A little searching in the forum would reveal this thread:

http://forums.arcgis.com/threads/69878-Solution-switching-between-tiled-services-in-different-projec....

and several more.
0 Kudos
PremRadhakrishnan
New Contributor III
Thanks Robert, we just finished implementing something very similar . I spent a lot of time searching yesterday and this had to be theone thread that I did not see! I did see a couple of threads where you had replied with a similar approach that I had taken in the firstpost of this thread.


Premkrishnan,

   A little searching in the forum would reveal this thread:

http://forums.arcgis.com/threads/69878-Solution-switching-between-tiled-services-in-different-projec....

and several more.
0 Kudos