This question is locked. New answers and comments are not allowed.
Hi,
I am using the sample code to get the best view of items in my map. It works fine for the first time, but when I leave the page where the map is and then return back I am getting incorrect zoom level (negative large number).
The only difference between these two calls of the method is the zoom level of the map. First time it is, as just being initialized, one, but second time it remains set as it was for the best view and the new zoom level is calculated incorrectly. I tried to put a breakpoint inside of the method and when hit I changed the zoomlevel of the map back to 1 before it is assigned to rect.MapControl. New zoom level was calculated correctly.
What is the reason for this behaviour?
Code used is bellow. No chages made in the layer between two OnLoaded events.
void InformationLayer_WPTs_Loaded(object sender, RoutedEventArgs e)
{
LocationRect rect = this.InformationLayer_WPTs.GetBestView(this.InformationLayer_WPTs.Items);
rect.MapControl = this.radMap;
this.radMap.Center = rect.Center;
this.radMap.ZoomLevel = rect.ZoomLevel;
}
Thanks,
Jakub
I am using the sample code to get the best view of items in my map. It works fine for the first time, but when I leave the page where the map is and then return back I am getting incorrect zoom level (negative large number).
The only difference between these two calls of the method is the zoom level of the map. First time it is, as just being initialized, one, but second time it remains set as it was for the best view and the new zoom level is calculated incorrectly. I tried to put a breakpoint inside of the method and when hit I changed the zoomlevel of the map back to 1 before it is assigned to rect.MapControl. New zoom level was calculated correctly.
What is the reason for this behaviour?
Code used is bellow. No chages made in the layer between two OnLoaded events.
void InformationLayer_WPTs_Loaded(object sender, RoutedEventArgs e)
{
LocationRect rect = this.InformationLayer_WPTs.GetBestView(this.InformationLayer_WPTs.Items);
rect.MapControl = this.radMap;
this.radMap.Center = rect.Center;
this.radMap.ZoomLevel = rect.ZoomLevel;
}
Thanks,
Jakub