Rotate map extent

2576
8
03-13-2014 12:11 PM
MelitonTienda_Avila
New Contributor
Hello Guys.
I need to set the major extent to map for
visualize one line geometry when i rotate map.

The next image shows the goal.

Hope you can help me..

Regards
0 Kudos
8 Replies
AhmedEl-Sisi
Occasional Contributor III
Try zooming to your feature using Map.ZoomTo Method After rotation.
0 Kudos
MelitonTienda_Avila
New Contributor
Hi,

I've tried to zoom to the geometry after rotation map, but I'm still having the problem

Regards..
0 Kudos
AhmedEl-Sisi
Occasional Contributor III
It's about aspect ratio of your map.
Try to keep Width/Height ration near 1.0
0 Kudos
MelitonTienda_Avila
New Contributor
Hi, Thanks for your reply.

My map is Height=300, and Width=700.

Do you have any example that you can give me?

I would appreciate...
0 Kudos
AhmedEl-Sisi
Occasional Contributor III
Try to change your map width/height to be equal.
0 Kudos
MelitonTienda_Avila
New Contributor
Thanks for your sample code.

But I can´t change the width and height map properties.
I need to keep this properties for save map image after rotate process in a pdf report like next image shows.
0 Kudos
AhmedEl-Sisi
Occasional Contributor III
Try This Zoom Method, Use it in the previous sample and enhance it according to your business.
         private void ZoomToGraphic()
        {
            if (activeGraphic != null && activeGraphic.Geometry != null)
            {
                var graphicExtent = activeGraphic.Geometry.Extent;
                var mapExtent = MyMap.Extent;
                double mapExtentWidth = mapExtent.XMax - mapExtent.XMin;
                double mapExtentHeight = mapExtent.YMax - mapExtent.YMin;
                if (MyMap.Rotation != 0)
                {
                    mapExtentHeight = mapExtent.XMax - mapExtent.XMin;
                    mapExtentWidth = mapExtent.YMax - mapExtent.YMin;
                }
                //Just Center the map to your graphic
                MyMap.PanTo(graphicExtent.GetCenter());
                //Zoom using factor.
                double xRatio = mapExtentWidth / graphicExtent.Width;
                double yRatio = mapExtentHeight /graphicExtent.Height;
                MyMap.Zoom(xRatio > yRatio ? yRatio : xRatio);
            }
        }


Regards,
0 Kudos
MelitonTienda_Avila
New Contributor
Thanks for your sample code it's very useful for me.
But in map rotation scenario can be any rotation angle.
The example works fine for 90 degrees rotation but for Map.Rotation = -45 not.

I apologize for not describe it.
Any Suggestion for this approach?

Thanks.
0 Kudos