I try to save the map to the image like this:
private MemoryStream LocationsToImage(ICollection<LocationType> locationCollection, Size size)
{
var map = new RadMap
{
Language = XmlLanguage.GetLanguage(CultureInfo.DefaultThreadCurrentCulture.Name),
Width = size.Width,
Height = size.Height
};
var layer = new InformationLayer();
map.Items.Add(layer);
MapHelper.DrawLocations(map, layer, locationCollection);
//print
map.Arrange(new Rect(size));
map.Measure(size);
map.Provider = MapProviderFactory.Create();
using var ms = new MemoryStream();
map.ExportToImage(@"C:\New Test.png", true);
return ms;
}
And the result I get:
But if I use for a map that is displayed in the UI it will be printed properly
But also regarding a map that is not displayed in the UI and was created here (as in the code above) I can use PrintVisual and print it properly.
private void LocationsToImage(ICollection<LocationType> locationCollection, Size size)
{
var map = new RadMap
{
Language = XmlLanguage.GetLanguage(CultureInfo.DefaultThreadCurrentCulture.Name),
Width = size.Width,
Height = size.Height
};
var layer = new InformationLayer();
map.Items.Add(layer);
MapHelper.DrawLocations(map, layer, locationCollection);
//print
map.Arrange(new Rect(size));
map.Measure(size);
map.Provider = MapProviderFactory.Create();
var pd = new PrintDialog();
if (pd.ShowDialog().GetValueOrDefault())
{
pd.PrintVisual(map, string.Empty);
}
}
So how can I use ExportToImage for a map that I create in code and not in view?