Access to MAP from ViewModel

559
2
11-05-2013 02:20 AM
AnatoliiTerentiev
Occasional Contributor III
Dear, Gurus!
I have next xaml:
        
<esri:Map x:Name="MyMap" >
            <esri:ArcGISDynamicMapServiceLayer 
                ID="Layers" 
                Url="http://myComp:6080/ArcGIS/rest/services/rkv_web/MapServer"/>
</esri:Map>

In ViewModel I have X,Y of point to pan to . How I can do some like that:
MyMap.PanTo(point);

That is how me to address to Mymap?
0 Kudos
2 Replies
JohanCarlsson
Occasional Contributor
ESRI.ArcGIS.Client.Geometry.MapPoint point = new ESRI.ArcGIS.Client.Geometry.MapPoint()
{
    X = x,
    Y = y,
    SpatialReference = MapApplication.Current.Map.SpatialReference.WKID
};
MapApplication.Current.Map.PanTo(point);
0 Kudos
DenisT
by
New Contributor III
The other approach is to have an event in VM and a behavior (for example) for a Map. Maybe weak event if you want to reuse your VMs and avoid memory leaks.
Makes sense if you decide to keep your VM layer clean from UI and platform-specific assemblies like ESRI.ArcGIS.Client.
It could be a painful approach in some cases.
0 Kudos