Hi
I want to save the state of a View.
I save in a xml file :
UpperLeftPoint.X Y Right…, CenterPoint of currentExtent
CurrentScale of MapView,
And the rotation (because I have a RotationProjection on the layers)
When I load my project, I read the xml file and I want to apply.
I apply this, just after the load of the layers and after a Mapview.refresh()
But because Mapview.Width and Mapview.Hight is 0, imossible to apply.
Do you a sample to load a configuration of a Map?
Thanks
Laurent M
Save states of MapView
Hi Maumet,
May I know you if you are initializing the map on activity create event? If yes, then we don’t need to call the Refresh method manually in this event, as the map will be refresh later automatically. So, in this event, we just need to load the map information from xml file and then assign the values to the map without refreshing the map.
Btw, we can also use this refresh method but please use the below codes instead. The codes will make the refresh a lazy calling method.
androidMap.Post(() => {
androidMap.Refresh(); });
Thanks,
Troy
Hi
I have a problem with the CurrentExtend and the RotationProjection.
I put CurrentExtend on my Mapview.
I put a Angle on my RotationProjection.
And I change the CurrentExtend of my MapView with GetUpdatedExtend
private RotationProjection rotationProjection;
androidMap.CurrentExtent = new RectangleShape(489345, 6616732, 504008, 6607778);
rotationProjection.Angle = -90;
androidMap.CurrentExtent = rotationProjection.GetUpdatedExtent(androidMap.CurrentExtent);
The CurrentExtend are the same. The GetUpdatedExtend has no effect
Thank you
Laurent M
Hi Maumet,
We can’t use the “GetUpdatedExtent” method to rotate a shape, this method will only return an adjusted extent based on the rotated extent, so, this method is not meet your case. Please try to use the Rotate method as the below:
PolygonShape extentPolygon = extent.ToPolygon();
extentPolygon.Rotate(extent.GetCenterPoint(), 270);
Thanks,
Troy
Hi Troy
I have the extents of a Map and a rotation.
When I load the map, I load my layers with a Rotation (through ManagedProj4Projection), I want to apply my extends.
But the coordinates of the extends are not rotate and the view is good.
I can transforme the coordinate with ManagedProj4Projection.ConvertToExternalProjection and make a new rectangle and use the extends of the rec tagle to have the new extend
But I have a error, when I make the rectangle, because I think that the UpperLeftPoint, UpperRightPoint, LowerRightPoint, LowerLeftPoint are
inconsistent.
Thanks,
Laurent M
Hi
I resolve my problem.
To save the parameters of my my Map:
I read UpperLeftPoint, UpperRightPoint, LowerRightPoint, LowerLeftPoint and convert those with ConvertToInternalProjection.
I search the Min and Max X,Y (They changed with the rotation) and I save those with the rotation.
When I load, I apply the rotation and the X,Y values to the extend of my map.
Thanks
Laurent M
Hi Laurent,
Great to hear you figure it out. Don’t hesitate to let us know.
Thanks,
Troy