XServer.NET and WPF
Posted: Wed Oct 26, 2022 8:05 am
Here's some sample code for "how to use xServer.NET control within a WPF based application to access PTV Developer" - thanks to Oliver for the code!
( Here's also some sample for xServer access )
Bernd
Window1.xaml
Window1.xaml.cs
( Here's also some sample for xServer access )
Bernd
Window1.xaml
Code: Select all
<Window x:Class="Demo.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mapcore="clr-namespace:Ptv.XServer.Controls.Map;assembly=Ptv.XServer.Controls.Map"
Title="Window1" Height="600" Width="800" Loaded="Window_Loaded">
<Grid>
<mapcore:WpfMap Name="Map" Center="8.4, 49" Zoom="12" />
</Grid>
</Window>
Code: Select all
using System.Windows;
using Ptv.XServer.Controls.Map.Layers.Tiled;
using Ptv.XServer.Controls.Map.Localization;
using Ptv.XServer.Controls.Map.TileProviders;
namespace Demo
{
public partial class Window1
{
public Window1()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var apiKey = "...";
Map.Layers.Add(new TiledLayer("BaseMap")
{
TiledProvider = new RemoteTiledProvider
{
MinZoom = 0,
MaxZoom = 22,
RequestBuilderDelegate = (x, y, z) =>
$"https://api.myptv.com/rastermaps/v1/image-tiles/{z}/{x}/{y}?style=silkysand&apiKey={apiKey}",
},
IsBaseMapLayer = true,
Copyright = "© 2022 PTV Group, HERE",
Caption = MapLocalizer.GetString(MapStringId.Background),
Icon = Ptv.XServer.Controls.Map.Tools.ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/Background.png")
});
}
}
}