public void InsertXMapBaseLayers(LayerCollection layers, XMapMetaInfo meta, string profile) { var baseLayer = new TiledLayer("Background") { TiledProvider = new ExtendedXMapTiledProvider(meta.Url, meta.User, meta.Password) { ContextKey = "in case of context key", CustomProfile = profile + "-bg", }, Copyright = meta.CopyrightText, Caption = MapLocalizer.GetString(MapStringId.Background), IsBaseMapLayer = true, Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/Background.png"), }; var labelLayer = new UntiledLayer("Labels") { UntiledProvider = new XMapTiledProvider( meta.Url, XMapMode.Town) { User = meta.User, Password = meta.Password, ContextKey = "in case of context key", CustomProfile = profile + "-fg", }, Copyright = meta.CopyrightText, MaxRequestSize = meta.MaxRequestSize, Caption = MapLocalizer.GetString(MapStringId.Labels), Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/Labels.png"), }; layers.Add(baseLayer); layers.Add(labelLayer); }
public static void InsertDataManagerLayer(this Map map, XMapMetaInfo xMapMetaInfo, string layerName, string layerId, string layerCaption, int minZoom = 0, bool markerIsBalloon = false) { var layer = new XMapLayer(layerName, xMapMetaInfo.Url, xMapMetaInfo.User, xMapMetaInfo.Password) { Caption = layerCaption, MaxRequestSize = new System.Windows.Size(2048, 2048), MinLevel = minZoom, Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/POI.png"), CustomXMapLayers = new xserver.Layer[] { new xserver.SMOLayer { name = layerId + "." + layerId, // Request REFERENCEPOINT based object information to provide tool tips on the icons. objectInfos = xserver.ObjectInfoType.REFERENCEPOINT, visible = true } }, Profile = "ajax-av", CustomCallerContextProperties = new[] { new CallerContextProperty { key = "ProfileXMLSnippet", value = "/profiles/datamanager/xmap/" + layerId } }, MarkerIsBalloon = markerIsBalloon, GetToolTipFromLayerObject = o => o.descr.Split('#')[1].Trim('|').Replace("|", "\n") }; map.Layers.Add(layer); }
/// <summary> /// Setting all relevant information for a PTV xServer, consisting of an URL and, in case of an on-premise xServer installation, /// an customer-provided xToken. The internally available user-password-pair is not used due to its visibility during sending /// requests to the xServer. /// </summary> /// <param name="url">URL of the xServer installation.</param> /// <param name="xToken">Value provided to the customer, which grants access only to the xServer API, and no further /// rights in the context of the internal user management.</param> /// <returns>False if the settings denied access due to a wrong URL address or authentication data, otherwise true.</returns> public static bool Set(string url, string xToken) { try { #region doc:CheckConnection var newXMapMetaInfo = new XMapMetaInfo(url); newXMapMetaInfo.SetCredentials("xtok", xToken); newXMapMetaInfo.CheckCredentials("xtok", xToken); // causes an exception if something goes wrong #endregion XMapMetaInfo = newXMapMetaInfo; IsOk = true; ErrorMessage = string.Empty; // Save settings for the next session Properties.Settings.Default.XUrl = url; Properties.Settings.Default.XToken = xToken; Properties.Settings.Default.Save(); } catch (Exception exception) { IsOk = false; ErrorMessage = exception.Message; } return(IsOk); }
/// <summary> /// Helper class that returns a region for an xServer meta info /// </summary> /// <param name="info">The meta info class</param> /// <returns>The region</returns> public static Region GetRegion(this XMapMetaInfo info) { var regex = new Regex(@"xmap-([a-z]+-[hnt](?:-test|-integration)?)\.cloud\.ptvgroup\.com", RegexOptions.IgnoreCase); var match = regex.Match(info.Url); var cluster = (match.Success) ? match.Groups[1].ToString() : String.Empty; if (string.IsNullOrEmpty(cluster)) { return(Region.world); } if (cluster.Contains("eu-n") || cluster.Contains("eu-t")) { return(Region.eu); } else if (cluster.Contains("na-n") || cluster.Contains("na-t")) { return(Region.na); } else if (cluster.Contains("au-n") || cluster.Contains("au-t")) { return(Region.au); } else { return(Region.world); } }
/// <summary> /// Inserts a road editor layer into the map. At the very base, "Truck Attributes" is road editor content. /// </summary> /// <param name="map">The new road editor layer will be inserted into this map instance, used as an extension.</param> /// <param name="xMapMetaInfo">Meta information, containing the xMap Server URL and authentication information, needed for layer access.</param> /// <param name="layerName">The name used in the map control to identify the layer.</param> /// <param name="xmapName">The xMap Server layer name</param> /// <param name="xmapProfile">The xMap Server profile to use. See remarks below.</param> /// <param name="layerCaption">The layer caption, used e.g. in the quick settings of the map control.</param> /// <remarks> /// Due to a restriction of xMap Server, road editor rendering is dependent on the street layer and requires /// the street layer to be visible. If the street layer is invisible, the road editor content will be invisible /// also. By default, the provider used by XMapLayer turns the street layer off, so it must explicitly be enabled /// through XMapLayer.CustomXMapLayers. As a side effect, enabling the street layer makes its contents visible in /// the map. To hide this content, to display only the road editor content, a special rendering profile will /// usually be used. For this reason this method provides an additional profile parameter where the rendering /// profile can be specified. /// /// The demo server incorporated into this sample was deployed with the necessary profiles to display Truck /// Attributes correctly. The xMap Server profile along with its rendering profile can be viewed / downloaded /// using the following management console links: /// /// xMap profile: /// https://xroute-eu-n-test.cloud.ptvgroup.com/xroute/rrxmap/pages/viewConfFileFormatted.jsp?name=xmap-truckattributes.properties /// /// Corresponding rendering profile: /// https://xroute-eu-n-test.cloud.ptvgroup.com/xroute//rrxmap/pages/viewConfFileFormatted.jsp?name=truckattributes.ini /// </remarks> public static void InsertRoadEditorLayer(this Map map, XMapMetaInfo xMapMetaInfo, string layerName, string xmapName, string xmapProfile, string layerCaption) { var roadEditorLayer = new XMapLayer(layerName, xMapMetaInfo.Url, xMapMetaInfo.User, xMapMetaInfo.Password) { Caption = layerCaption, Profile = xmapProfile, MaxRequestSize = new System.Windows.Size(2048, 2048), MinLevel = 14, Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/RoadEditor.png"), CustomXMapLayers = new Layer[] { new RoadEditorLayer { // Road Editor element. Request REFERENCEPOINT based object // information to provide tool tips on the signs. name = xmapName, // Request REFERENCEPOINT based object information to // provide tool tips on the signs. objectInfos = ObjectInfoType.REFERENCEPOINT, visible = true }, new StaticPoiLayer { // see remarks above about street layer element name = "street", visible = true, category = -1, detailLevel = 0 } } }; map.Layers.Add(roadEditorLayer); }
public void InsertXMapBaseLayers(LayerCollection layers, XMapMetaInfo meta, string profile) { var baseLayer = new TiledLayer("Background") { TiledProvider = new ExtendedXMapTiledProvider(meta.Url, meta.User, meta.Password) { ContextKey = "in case of context key", CustomProfile = profile + "-bg" }, Copyright = meta.CopyrightText, Caption = MapLocalizer.GetString(MapStringId.Background), IsBaseMapLayer = true, Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/Background.png") }; var labelLayer = new UntiledLayer("Labels") { UntiledProvider = new XMapTiledProvider( meta.Url, XMapMode.Town) { User = meta.User, Password = meta.Password, ContextKey = "in case of context key", CustomProfile = profile + "-fg" }, Copyright = meta.CopyrightText, MaxRequestSize = meta.MaxRequestSize, Caption = MapLocalizer.GetString(MapStringId.Labels), Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/Labels.png") }; layers.Add(baseLayer); layers.Add(labelLayer); }
private void InitMapLayers() { Map.SetMapLocation(new System.Windows.Point(8.4044, 49.01405), 14); Map.Layers.Clear(); var meta = new XMapMetaInfo("https://api-test.cloud.ptvgroup.com/xmap/ws/XMap"); meta.SetCredentials("xtok", token); XMapLayerFactory.InsertXMapBaseLayers(Map.Layers, meta); Map.XMapStyle = "gravelpit"; xynLayer = new XynLayer(meta, "xyn", "XYN Segments") { UntiledProvider = new XMapTiledProvider(meta.Url, XMapMode.Custom) { User = meta.User, Password = meta.Password, } }; Map.Layers.Add(xynLayer); Map.MouseDown += Map_MouseDown; }
/// <summary> /// Get the meta info from xServer /// </summary> /// <returns></returns> private XMapMetaInfo GetMetaInfo() { // the tools class XMapMetaInfo contains the information required to intialize the xServer layers // When instantiated with the url, it tries to read the attribution text and the maximum request size from the xMap configuration // var meta = new XMapMetaInfo("http://127.0.0.1:50010/xmap/ws/XMap"); // custom xmap with reverse proxy var meta = new XMapMetaInfo("https://xmap-eu-n-test.cloud.ptvgroup.com/xmap/ws/XMap"); // xServer internet meta.SetCredentials("xtok", "561677741926322"); // set the basic authentication properties, e.g. xtok/token for xserver internet return meta; }
public XynLayer(XMapMetaInfo meta, string layerName, string layerCaption) : base(layerName) { // note: the class XMapTiledProvider implements both the interface for tiled and non-tiled layers! UntiledProvider = new XMapTiledProvider(meta.Url, XMapMode.Custom) { User = meta.User, Password = meta.Password, }; Caption = layerCaption; MinLevel = 4; Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/RoadEditor.png"); }
private void InitMapLayers() { const string cluster = "eu-n-test"; Map.SetMapLocation(new Point(9.182778, 48.775556), 12); var xmapMetaInfo = new XMapMetaInfo("https://xmap-" + cluster + ".cloud.ptvgroup.com/xmap/ws/XMap"); xmapMetaInfo.SetCredentials("xtok", "Insert your xToken here"); InsertXMapBaseLayers(Map.Layers, xmapMetaInfo, "gravelpit"); Map.InsertTrafficInfoLayer(xmapMetaInfo, "Traffic", "traffic.ptv-traffic", "Traffic information"); Map.InsertRoadEditorLayer(xmapMetaInfo, "TruckAttributes", "truckattributes", "truckattributes", "Truck attributes"); Map.InsertPoiLayer(xmapMetaInfo, "Poi", "default.points-of-interest", "Points of interest"); }
/// <summary> /// Inserts the xMapServer base layers, i.e. the background layers for areas like forests, rivers, population areas, et al, /// and their corresponding labels. /// </summary> /// <param name="layers">The LayerCollection instance, used as an extension. </param> /// <param name="meta">Meta information for xMapServer, further details can be seen in the <see cref="XMapMetaInfo"/> description. </param> public static void InsertXMapBaseLayers(this LayerCollection layers, XMapMetaInfo meta) { var baseLayer = new TiledLayer(BackgroundLayerName) { TiledProvider = new XMapTiledProvider(meta.Url, meta.User, meta.Password, XMapMode.Background), Copyright = meta.CopyrightText, Caption = MapLocalizer.GetString(MapStringId.Background), IsBaseMapLayer = true, Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/Background.png") }; if (BaseLayerSuccessor != null && layers[BaseLayerSuccessor] != null) { layers.Insert(layers.IndexOf(layers[BaseLayerSuccessor]), baseLayer); } else { // add tile layer layers.Add(baseLayer); BaseLayerSuccessor = null; } // don't add overlay layer for Decarta-powered maps (basemap is completely rendered on tiles) if (XServerUrl.IsDecartaBackend(meta.Url)) { return; } var labelLayer = new UntiledLayer(LabelsLayerName) { UntiledProvider = new XMapTiledProvider(meta.Url, meta.User, meta.Password, XMapMode.Town), MaxRequestSize = meta.MaxRequestSize, Caption = MapLocalizer.GetString(MapStringId.Labels), Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/Labels.png") }; if (LabelLayerPredecessor != null && layers[LabelLayerPredecessor] != null && layers.IndexOf(layers[LabelLayerPredecessor]) < layers.Count) { layers.Insert(layers.IndexOf(layers[LabelLayerPredecessor]) + 1, labelLayer); } else { // add label layer layers.Add(labelLayer); LabelLayerPredecessor = null; } }
public void Initialize(Map map) { map.Layers.RemoveXMapBaseLayers(); string adjustedUrl = AdjustedUrl(); if (string.IsNullOrEmpty(adjustedUrl)) { return; } var xmapMetaInfo = new XMapMetaInfo(adjustedUrl); if (XMapCredentials?.Contains(":") ?? false) { var userPassword = XMapCredentials.Split(':'); xmapMetaInfo.SetCredentials(userPassword[0], userPassword[1]); } map.Layers.InsertXMapBaseLayers(xmapMetaInfo); }
/// <summary> /// Inserts a POI layer into the map. /// </summary> /// <param name="map">The new POI layer will be inserted into this map instance, used as an extension.</param> /// <param name="xMapMetaInfo">Meta information, containing the xMap Server URL and authentication information, needed for layer access.</param> /// <param name="layerName">The name used in the map control to identify the layer.</param> /// <param name="xmapName">The xMap Server layer name. See remarks below.</param> /// <param name="layerCaption">The layer caption, for example used in the quick settings of the map control.</param> /// <remarks> /// The POI layer does not require a special profile. xmapName has to be provided in the form /// <configuration>.<layername>[.<profile>][;<SQL Filter>] as specified by xMap Server. Please /// refer to the xMap Server documentation for details. /// </remarks> public static void InsertPoiLayer(this Map map, XMapMetaInfo xMapMetaInfo, string layerName, string xmapName, string layerCaption) { var layer = new XMapLayer(layerName, xMapMetaInfo.Url, xMapMetaInfo.User, xMapMetaInfo.Password) { Caption = layerCaption, MaxRequestSize = new System.Windows.Size(2048, 2048), MinLevel = 14, Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/POI.png"), CustomXMapLayers = new xserver.Layer[] { new xserver.SMOLayer { name = xmapName, // Request REFERENCEPOINT based object information to provide tool tips on the icons. objectInfos = xserver.ObjectInfoType.REFERENCEPOINT, visible = true } } }; map.Layers.Add(layer); }
/// <summary> /// Inserts a Traffic Information layer into the map. /// </summary> /// <param name="map">The new Traffic Information layer will be inserted into this map instance, used as an extension.</param> /// <param name="xMapMetaInfo">Meta information, containing the xMap Server URL and authentication information, needed for layer access.</param> /// <param name="layerName">The name used in the map control to identify the layer.</param> /// <param name="xmapName">The xMap Server layer name. See remarks below.</param> /// <param name="layerCaption">The layer caption, used e.g. in the quick settings of the map control.</param> /// <remarks> /// The Traffic Information layer does not require a special profile. Note that the layer requests /// object information of type xserver.ObjectInfoType.FULLGEOMETRY to enable tool tips along the /// lines displayed. /// /// xmapName has to be provided in the form <configuration>.<layername>[.<profile>][;<SQL Filter>] as /// specified by xMap Server. Please refer to the xMap Server documentation for details. /// </remarks> public static void InsertTrafficInfoLayer(this Map map, XMapMetaInfo xMapMetaInfo, string layerName, string xmapName, string layerCaption) { var layer = new XMapLayer(layerName, xMapMetaInfo.Url, xMapMetaInfo.User, xMapMetaInfo.Password) { Caption = layerCaption, MaxRequestSize = new System.Windows.Size(2048, 2048), MinLevel = 10, CustomXMapLayers = new Layer[] { new SMOLayer { name = xmapName, // request object information of type FULLGEOMETRY // to enable tool tips along the lines displayed. objectInfos = ObjectInfoType.FULLGEOMETRY, visible = true } } }; map.Layers.Add(layer); }
/// <summary> /// Inserts a POI layer into the map. /// </summary> /// <param name="map">The new POI layer will be inserted into this map instance, used as an extension.</param> /// <param name="xMapMetaInfo">Meta information, containing the xMap Server URL and authentication information, needed for layer access.</param> /// <param name="layerName">The name used in the map control to identify the layer.</param> /// <param name="xmapName">The xMap Server layer name. See remarks below.</param> /// <param name="layerCaption">The layer caption, for example used in the quick settings of the map control.</param> /// <remarks> /// The POI layer does not require a special profile. xmapName has to be provided in the form /// <configuration>.<layername>[.<profile>][;<SQL Filter>] as specified by xMap Server. Please /// refer to the xMap Server documentation for details. /// </remarks> public static void InsertPoiLayer(this Map map, XMapMetaInfo xMapMetaInfo, string layerName, string xmapName, string layerCaption) { var layer = new XMapLayer(layerName, xMapMetaInfo.Url, xMapMetaInfo.User, xMapMetaInfo.Password) { Caption = layerCaption, MaxRequestSize = new System.Windows.Size(2048, 2048), MinLevel = 14, Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/POI.png"), CustomXMapLayers = new Layer[] { new SMOLayer { name = xmapName, // Request REFERENCEPOINT based object information to provide tool tips on the icons. objectInfos = ObjectInfoType.REFERENCEPOINT, visible = true } } }; map.Layers.Add(layer); }
public void InsertXMapBaseLayers(LayerCollection layers, XMapMetaInfo meta) { InsertXMapBaseLayers(layers, meta.Url, meta.CopyrightText, meta.MaxRequestSize, meta.User, meta.Password); }
/// <summary> /// Inserts a road editor layer into the map. At the very base, "Truck Attributes" is road editor content. /// </summary> /// <param name="map">The new road editor layer will be inserted into this map instance, used as an extension.</param> /// <param name="xMapMetaInfo">Meta information, containing the xMap Server URL and authentication information, needed for layer access.</param> /// <param name="layerName">The name used in the map control to identify the layer.</param> /// <param name="xmapName">The xMap Server layer name</param> /// <param name="xmapProfile">The xMap Server profile to use. See remarks below.</param> /// <param name="layerCaption">The layer caption, used e.g. in the quick settings of the map control.</param> /// <remarks> /// Due to a restriction of xMap Server, road editor rendering is dependent on the street layer and requires /// the street layer to be visible. If the street layer is invisible, the road editor content will be invisible /// also. By default, the provider used by XMapLayer turns the street layer off, so it must explicitly be enabled /// through XMapLayer.CustomXMapLayers. As a side effect, enabling the street layer makes its contents visible in /// the map. To hide this content, to display only the road editor content, a special rendering profile will /// usually be used. For this reason this method provides an additional profile parameter where the rendering /// profile can be specified. /// /// The demo server incorporated into this sample was deployed with the necessary profiles to display Truck /// Attributes correctly. The xMap Server profile along with its rendering profile can be viewed / downloaded /// using the following management console links: /// /// xMap profile: /// https://xroute-eu-n-test.cloud.ptvgroup.com/xroute/rrxmap/pages/viewConfFileFormatted.jsp?name=xmap-truckattributes.properties /// /// Corresponding rendering profile: /// https://xroute-eu-n-test.cloud.ptvgroup.com/xroute//rrxmap/pages/viewConfFileFormatted.jsp?name=truckattributes.ini /// </remarks> public static void InsertRoadEditorLayer(this Map map, XMapMetaInfo xMapMetaInfo, string layerName, string xmapName, string xmapProfile, string layerCaption) { var roadEditorLayer = new XMapLayer(layerName, xMapMetaInfo.Url, xMapMetaInfo.User, xMapMetaInfo.Password) { Caption = layerCaption, Profile = xmapProfile, MaxRequestSize = new System.Windows.Size(2048, 2048), MinLevel = 14, Icon = ResourceHelper.LoadBitmapFromResource("Ptv.XServer.Controls.Map;component/Resources/RoadEditor.png"), CustomXMapLayers = new xserver.Layer[] { new xserver.RoadEditorLayer { // Road Editor element. Request REFERENCEPOINT based object // information to provide tool tips on the signs. name = xmapName, // Request REFERENCEPOINT based object information to // provide tool tips on the signs. objectInfos=xserver.ObjectInfoType.REFERENCEPOINT, visible = true }, new xserver.StaticPoiLayer { // see remarks above about street layer element name = "street", visible = true, category = -1, detailLevel = 0 } } }; map.Layers.Add(roadEditorLayer); }
/// <summary> /// Inserts a Traffic Information layer into the map. /// </summary> /// <param name="map">The new Traffic Information layer will be inserted into this map instance, used as an extension.</param> /// <param name="xMapMetaInfo">Meta information, containing the xMap Server URL and authentication information, needed for layer access.</param> /// <param name="layerName">The name used in the map control to identify the layer.</param> /// <param name="xmapName">The xMap Server layer name. See remarks below.</param> /// <param name="layerCaption">The layer caption, used e.g. in the quick settings of the map control.</param> /// <remarks> /// The Traffic Information layer does not require a special profile. Note that the layer requests /// object information of type xserver.ObjectInfoType.FULLGEOMETRY to enable tool tips along the /// lines displayed. /// /// xmapName has to be provided in the form <configuration>.<layername>[.<profile>][;<SQL Filter>] as /// specified by xMap Server. Please refer to the xMap Server documentation for details. /// </remarks> public static void InsertTrafficInfoLayer(this Map map, XMapMetaInfo xMapMetaInfo, string layerName, string xmapName, string layerCaption) { var layer = new XMapLayer(layerName, xMapMetaInfo.Url, xMapMetaInfo.User, xMapMetaInfo.Password) { Caption = layerCaption, MaxRequestSize = new System.Windows.Size(2048, 2048), MinLevel = 10, CustomXMapLayers = new xserver.Layer[] { new xserver.SMOLayer { name = xmapName, // request object information of type FULLGEOMETRY // to enable tool tips along the lines displayed. objectInfos=xserver.ObjectInfoType.FULLGEOMETRY, visible = true } } }; map.Layers.Add(layer); }
private void InitMapLayers() { string cluster = GetCluster(); switch (cluster) { case "eu-n-test": Map.SetMapLocation(new System.Windows.Point(9.182778, 48.775556), 12); break; case "au-n-test": Map.SetMapLocation(new System.Windows.Point(138.6, -34.92), 12); break; case "na-n-test": Map.SetMapLocation(new System.Windows.Point(-71.415, 41.830833), 12); break; } Map.Layers.Clear(); var xmapMetaInfo = new XMapMetaInfo("https://xmap-" + cluster + ".cloud.ptvgroup.com/xmap/ws/XMap"); xmapMetaInfo.SetCredentials("xtok", "561677741926322"); InsertXMapBaseLayers(Map.Layers, xmapMetaInfo, GetProfile()); UpdateFeatureLayers(); Map.InsertTrafficInfoLayer(xmapMetaInfo, "Traffic", "traffic.ptv-traffic", "Traffic information"); Map.InsertRoadEditorLayer(xmapMetaInfo, "TruckAttributes", "truckattributes", "truckattributes", "Truck attributes"); Map.InsertPoiLayer(xmapMetaInfo, "Poi", "default.points-of-interest", "Points of interest"); if (cluster == "eu-n-test") Map.InsertDataManagerLayer(xmapMetaInfo, "POS", "t_f07ef3f0_ce7a_4913_90ea_b072ec07e6ff", "Points Of Sales", 10, true); }