ThinkGeo.com    |     Documentation    |     Premium Support

RotationProjection on EditOverlay/TrackOverlay

Is there an easy way to add a RotationProjection to the Edit/TrackOverlay of a map?  I've tried adding to the individual layers (DragControlPointsLayer, EditLayer ...etc.) and it seems to rotate fine, but if I drag a control point of a multi-line feature the control point moves in a different direction once I change the rotation (wrong extent being used in DragControlPointsLayer???).


Thanks,


Dave



Dave, 


We cannot add a RotationProjection to the Edit/trackOverlay as the features inside the TrackOverlay is already projected (if the map is using a projection). Here is a demo shows how to implement it in another way, please have a look.
 
Thanks!
 
Ben

721-Post5808.zip (11.5 KB)

Thanks.  Didn't seem to work for me right away but I was able to tweak it a bit and I'm good to go...


 


 



      /// <summary>
      /// User changed North location from UI
      /// </summary>
      /// <param name="sender">Ignored</param>
      /// <param name="e">Ignored</param>
      void m_panButton_AngleChanged( object sender, EventArgs e )
      {
         foreach ( Overlay overlay in m_map.Overlays )
         {
            overlay.Lock.EnterWriteLock();
         }
         try
         {
            double saveAngle = m_projection.Angle;
            //
            //Update the TrackOverlay.
            //
            m_map.TrackOverlay.Lock.EnterWriteLock();
            try
            {
               Collection<Feature> projectedTrackFeatures = new Collection<Feature>();
               foreach ( Feature feature in m_map.TrackOverlay.TrackShapeLayer.InternalFeatures )
               {
                  Feature projectedFeature =  m_projection.ConvertToInternalProjection(feature);
                  projectedTrackFeatures.Add(projectedFeature);
               }
               m_projection.Angle = m_panButton.RotationAngle;

               m_map.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear();
               foreach ( Feature feature in projectedTrackFeatures )
               {
                  m_map.TrackOverlay.TrackShapeLayer.InternalFeatures.Add(m_projection.ConvertToExternalProjection(feature));
               }
            }
            finally
            {
               m_map.TrackOverlay.Lock.ExitWriteLock();
            }
            //
            //Update the EditOverlay.
            //
            m_map.EditOverlay.Lock.EnterWriteLock();
            try
            {
               Collection<Feature> projectedEditFeatures = new Collection<Feature>();
               m_projection.Angle = saveAngle;
               foreach ( Feature feature in m_map.EditOverlay.EditShapesLayer.InternalFeatures )
               {
                  Feature projectedFeature = m_projection.ConvertToInternalProjection(feature);
                  projectedEditFeatures.Add(projectedFeature);
               }
               m_projection.Angle = m_panButton.RotationAngle;

               m_map.EditOverlay.EditShapesLayer.InternalFeatures.Clear();
               foreach ( Feature feature in projectedEditFeatures )
               {
                  m_map.EditOverlay.EditShapesLayer.InternalFeatures.Add(m_projection.ConvertToExternalProjection(feature));
               }

               m_map.EditOverlay.CalculateAllControlPoints();
            }
            finally
            {
               m_map.EditOverlay.Lock.ExitWriteLock();
            }

            m_map.CurrentExtent = m_projection.GetUpdatedExtent(m_map.CurrentExtent);
         }
         catch ( Exception )
         {
         }
         finally
         {
            foreach ( Overlay overlay in m_map.Overlays )
            {
               overlay.Lock.ExitWriteLock();
            }
         }

         RefreshMap();
      }



David, 
  
 Thanks for your sharing codes. Do not hesitate to let me know if any further questions. 
  
 Yale.