MapPropertyChangeEvent Issue with MapView Extent

272
2
01-24-2021 11:01 PM
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi Guys,

 

In my addin, I subscribe to MapPropertyChangeEvent to get updated spatialreference and extent of current map view.

I correctly get updated SpatialReference in the event, but I got MapView extent boundingbox values are remained the same as old spatialreference value.

I am using this code in the MapPropertyChangeEvent to get current MapView extent.

MapView.Active.Extent  

For example after I change map's spatial reference from projected coordinate system, 

From 

"PROJCS[\"AGD_1966_AMG_Zone_50\",GEOGCS[\"GCS_Australian_1966\",DATUM[\"D_Australian_1966\",SPHEROID[\"Australian\",6378160.0,298.25]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",500000.0],PARAMETER[\"False_Northing\",10000000.0],PARAMETER[\"Central_Meridian\",117.0],PARAMETER[\"Scale_Factor\",0.9996],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]"

to geographic

"GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]"

 

I am getting mapview extent boundingbox as in

XMax: -1776117.1635439098

    XMin: -1900502.3492182

    YMax: 12016785.670364719

    YMin: 11967047.984130006

 

I subcribed the map property change event in constructor and using arcgis pro sdk 2.7.  Is there any other way I can extract current mapview extent correctly upon spatial reference change.

 

Best Regards,

Than

Tags (1)
0 Kudos
2 Replies
KirkKuykendall1
Occasional Contributor III

At first glance, it looks like changing the SpatialRef also triggers a change in the camera.  When MapViewCameraChangedEvent occurs, the extent appears to be in sync with the spatialref.

ArcGIS.Desktop.Mapping.Events.MapViewCameraChangedEvent.Subscribe((e) =>
{
    try
    {
        if(e.PreviousCamera != null)
        {
            int previousWkid = e.PreviousCamera.SpatialReference.Wkid;
            var currentWkid = e.CurrentCamera.SpatialReference.Wkid;
            Debug.Print($"{previousWkid} {currentWkid} {MapView.Active.Extent.Width}");
        }
    }
    catch(Exception ex)
    {
        Debug.Print(ex.Message);
    }
});

 

0 Kudos
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi @KirkKuykendall1 ,

My question is that the bbox of extent value from mapview camera is wrong and still based on the previous spatialreference whereas spatialreference of its extent is updated.

Refer to my example : I update map spatialreference from projected to geographics, the value capture in map property change event is that value.

XMax: -1776117.1635439098

    XMin: -1900502.3492182

    YMax: 12016785.670364719

    YMin: 11967047.984130006

But yes, the bbox extent value become in sync in the camera view change event later on.

It seems pro sdk is still in progress of updating the extent value during the map property change event.

In my opinion, it is a bug, pro shouldn't update partial property value during map property change event as well, or may be because of thread issue.

If they decided to update bbox values of extent in Camera change event, should have done all update in that place.

 

0 Kudos