Rex Hansen wrote this thorough post about the new support for map rotation in version 9.2, Service Pack 2 of the Web ADF for the Microsoft® .NET Framework:
ArcGIS Server map services support the ability to serve a rotated data frame (map). In 9.2 SP 2, the .NET Web ADF has been enhanced to support map rotation. This involved a number of changes in many sections of the Web ADF. Each section is discussed below:
The Map control has a new Rotation property that can be used to specify, in degrees, the rotation of resources in the Map. A value of NaN means that the rotation of the PrimaryMapResource will be applied; 0 will unrotate rotated resources and leave other resources alone; values greater or less than 0 will rotate resources, throwing an exception if unrotatable resources are present. Map rotation is supported for ArcGIS Server (both Internet and Local) and Web ADF Graphics data sources.
If the Map control has a rotation value greater or less than 0:
- The presence of non-rotatable resources will return an exception in the Web page at runtime. The exception will indicate which resource does not support rotation.
- The ContinuousCallback and EnableTileCaching properties on the Map control will be disabled.
If the Map Rotation property is NaN, the rotation of the PrimaryMapResource (PMR) can be used. Since a Web ADF Graphics resource cannot be a PMR, only a rotation value specified for a data frame in an ArcGIS Server map service can be used.
Map rotation can also be set on the fly at runtime. As long as the resources in the Map control support rotation, Map contents will be updated. Again, if a resource does not support rotation, an exception will returned in the Web page indicating which resource.
The following code snippet illustrates how to change the Rotation property on a Map control:
Map1.Rotation = 45;
Rotating an ArcGIS Server cached map service requires that dynamic map images are generated – the cached map tiles will not be used. As a result, many of the performance benefits of a cached map service are negated.
Web ADF controls that work with the Map have also been updated to support rotation, such as the Navigation, Magnifier, and OverviewMap controls.
TransformationParams and RotationParams classes
Two new classes have been introduced to support parameters used when transforming and rotating map content: TransformationParams and RotationParams.
TransformationParams stores parameters needed to convert coordinates between screen and map units. The Map control has a GetTransformationParams() method to return a TransformationParams instance set up using Map properties. The TransformationDirection enumeration allows you to select which direction the transformation will take place: either screen to map units (ToMap) or map to screen units (ToScreen).
The RotationParams class stores parameters associated with a rotated map extent. The TransformationParams class uses the RotatedParams class to account for rotation when converting coordinates between screen and map units.
In most cases, you’ll use an instance of TransformationParams when converting geometry to and from screen and map units. This is discussed in more detail in the next section.
A set of static methods on the Web ADF Geometry, Point and Envelope classes (in ESRI.ArcGIS.ADF.Web.Geometry) used to convert to and from screen and map units have been overloaded to support map rotation. Previous methods of the same name in 9.2 final and 9.2 sp1 have been marked obsolete because they do not support rotated maps. Obsolete methods will still work with unrotated map content. The new overloads provide a more efficient pattern for transforming Web ADF geometry. A single TransformationParams instance can be created from scratch or retrieved from a Map control and used in multiple geometry conversion calls. TransformationDirection.ToMap should be used for ToMap_ methods while TransformationDirection.ToScreen should be used with ToScreen_ methods. The overloaded methods are listed below:
In the ESRI.ArcGIS.ADF.Web.Geometry.Geometry class (inherited by concrete Web ADF geometry classes):
In the ESRI.ArcGIS.ADF.Web.Geometry.Point class:
ToMapPoint(int, int, ESRI.ArcGIS.ADF.Web.Geometry.TransformationParams)
In the ESRI.ArcGIS.ADF.Web.Geometry.Envelope class:
The following code snippet illustrates how to convert from a point in screen units to a Web ADF Point object in map units:
ESRI.ArcGIS.ADF.Web.Geometry.Point adfPoint = ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screenPoint.X, screenPoint.Y, Map1.GetTransformationParams(TransformationDirection.ToMap);
When building a Web application in Manager, the Map rotation property is set to a value of NaN and cannot be changed explicitly. Instead, the Primary Map Resource (PMR) can be used to define a rotation value. In Manager, the PMR is set in the Preview Layers dialog by selecting a resource in the drop down list under “Use coordinate system, rotation and extent of:”. If the PMR is rotated, you cannot use non-rotatable service types, such as ArcIMS and WMS, in the same map. Manager will provide an informative warning if this situation occurs. If you select a non-rotatable service as the PMR, the Web ADF will unrotate any rotated service so that it lines up with the non-rotatable service.