We're using the Map controls (via a FormsMap control) and set the XMapUrl. When it's a xServer 2, it takes a while before the map appears, since it checks first if it's an xServer 1 (the setter of the property actually performs a WebRequest with timeout of 5 seconds. When I know that I have an xServer 2, this wastes some time that the user has to wait before the actual map appears.
This could maybe fixed by a property in Map, e.g. UseXserver2Only or something. @oliverheilig what do you think? Or is there alternative ways to skip the xServer 1 check?
Map control with xServer 2 only (how to optimize performance)
- Bernd Welter
- Site Admin
- Posts: 2740
- Joined: Mon Apr 14, 2014 10:28 am
- Contact:
Map control with xServer 2 only (how to optimize performance)
These days some xServer.NET users asked in the github.
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany
Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning...
Technical Partner Manager Developer Components
PTV Logistics - Germany
Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning...
- Oliver Heilig
- Posts: 160
- Joined: Tue May 13, 2014 12:10 pm
- Location: Karlsruhe, Germany
- Contact:
Re: Map control with xServer 2 only (how to optimize performance)
It is possible to skip the automatic initialization/probing by inserting the layers programmatically.
xserver-1
* Initialize the xmap layers explictly, without automatic setup, snippet
* A more lightweight variant is using the REST/API, snippet. This is more efficient if only the basemap layers are needed.
xserver2
xMap-2 can be added as generic tile layer. When Featurelayer-overlays with tooltips are needed, these can be added via the UntiledLayer.
xserver-1
* Initialize the xmap layers explictly, without automatic setup, snippet
* A more lightweight variant is using the REST/API, snippet. This is more efficient if only the basemap layers are needed.
xserver2
xMap-2 can be added as generic tile layer. When Featurelayer-overlays with tooltips are needed, these can be added via the UntiledLayer.
Code: Select all
private void Form1_Load(object sender, EventArgs e)
{
formsMap1.SetMapLocation(new System.Windows.Point(8.4044, 49.01405), 15);
formsMap1.MaxZoom = 22;
string storedProfile = "silkysand";
string token = "....";
// Initialize the base map as generic tile layer, but only with background/transport activated
formsMap1.Layers.Add(new TiledLayer("Background")
{
TiledProvider = new RemoteTiledProvider
{
MinZoom = 0,
MaxZoom = 22,
RequestBuilderDelegate = (x, y, z) =>
$"https://s0{(x + y) % 4 + 1}-xserver2-test.cloud.ptvgroup.com/services/rest/XMap/tile/{z}/{x}/{y}" +
$"?xtok={token}&storedProfile={storedProfile}&layers=background,transport"
},
IsBaseMapLayer = true,
Caption = MapLocalizer.GetString(MapStringId.Background),
Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/Background.png"),
Copyright = $"© {DateTime.Now.Year} PTV Group, HERE, TomTom",
});
// The overlays wit FeatureLayer content
formsMap1.Layers.Add(new UntiledLayer("Labels")
{
UntiledProvider = new UntiledProvider
{
RequestUriString = "https://xserver2-test.cloud.ptvgroup.com/services/rs/XMap/renderMap",
StoredProfile = storedProfile,
ThemesForRendering = new[] { "Labels", "PTV_TrafficIncidents" },
ThemesWithMapObjects = new[] { "PTV_TrafficIncidents" },
TimeConsiderationScenario = "SnapshotTimeConsideration",
TimeSpan = 1000,
ReferenceTime = DateTime.Now.ToString("o"),
XToken = token,
},
Caption = MapLocalizer.GetString(MapStringId.Labels),
Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/Labels.png"),
Copyright = $"© {DateTime.Now.Year} PTV Group, HERE, TomTom",
});
}
Oliver Heilig
Chief Developer Logistic Services
PTV GROUP - Germany
https://github.com/oliverheilig/
Chief Developer Logistic Services
PTV GROUP - Germany
https://github.com/oliverheilig/