Dear Gurus!
Unexpected problem.
For some operations I decide to show new tab with copy of the Map element from the current tab (in the tabControl).
<esri:Map x:Name="MyMap" Background="White" WrapAround="true" Extent="3200000,8500000,4250000,10130000"> <esri:OpenStreetMapLayer ID="OSMLayer" Style="Mapnik" /> <esri:ArcGISDynamicMapServiceLayer ID="Карта РК" Url="http://myServer:6080/ArcGIS/rest/services/karelia/MapServer" /> <esri:GraphicsLayer ID="MyGraphicsLayer" MouseLeftButtonDown="GraphicsLayer_MouseLeftButtonDown" /> </esri:Map>
And want to set centerPoint and resolution from the first tab. In the next event
<i:Interaction.Triggers> <i:EventTrigger EventName="Loaded"> <i:InvokeCommandAction Command="{Binding SetMapRefCommand, Mode=OneWay}" CommandParameter="{Binding ElementName=MyMap,Mode=OneWay}" /> </i:EventTrigger> </i:Interaction.Triggers>
as follows in the ViewModel for this control
public void SetMapRef(object item) { myMap = (Map)item; MapModule.ViewModels.MapViewModel.centerAndZoom(myMap, currentCentrPointFromFirst, MapResolutionFromFirst); }
Where centerAndZoom procedure is
public static void centerAndZoom(ESRI.ArcGIS.Client.Map map, ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint, double resolution)
{
double ratio = 1.0;
if (map.Resolution != 0.0)
ratio = resolution / map.Resolution;
if (ratio == 1.0)
map.PanTo(mapPoint);
else
{
ESRI.ArcGIS.Client.Geometry.MapPoint mapCenter = map.Extent.GetCenter();
double X = (mapPoint.X - ratio * mapCenter.X) / (1 - ratio);
double Y = (mapPoint.Y - ratio * mapCenter.Y) / (1 - ratio);
map.ZoomToResolution(resolution, new ESRI.ArcGIS.Client.Geometry.MapPoint(X, Y));
}
}
But it does not work. When I do it from the click button Event - all works fine. I can't understand - what is the reason...
How to fix?
I want to create several views with the same Map element for different task. I am using Prism and want to be able to load views in the different regions with the same parameteres of the map. Can I do it and how if it is possible?