Hi,
I need an adaption of the example in the CookBook about the use of GeometryLayer form Java to c# WPF.
The code below unfortunately doesn't show the polyline:
xserver.GeometryOption[] test_geometryOptions = new xserver.GeometryOption[] {
new xserver.GeometryOption { option = xserver.GeometryOptions.BORDERCOLOR, value = rgbToColorString(0,128,255)},
new xserver.GeometryOption { option = xserver.GeometryOptions.FILLCOLOR, value = rgbToColorString(255,0,0)},
new xserver.GeometryOption { option = xserver.GeometryOptions.FILLALPHA, value = "200"}, // 0-255
new xserver.GeometryOption { option = xserver.GeometryOptions.AUTOCENTEROBJECTS, value = "1"} // 0-255
};
xserver.PlainPoint[] test_points = new xserver.PlainPoint[] {
new xserver.PlainPoint { x = 7.06654212202759, y = 41.3049992893457 },
new xserver.PlainPoint { x = 10.7403702470276, y = 41.2521586885924 },
new xserver.PlainPoint { x = 10.7052139970276, y = 38.6520066768626 },
new xserver.PlainPoint { x = 7.52357337202759, y = 38.5970748172508 },
new xserver.PlainPoint { x = 7.57630774702759, y = 41.1728175884917 }
};
xserver.PlainLinearRing test_plainLinearRing = new xserver.PlainLinearRing();
test_plainLinearRing.wrappedPoints = test_points;
xserver.Polygon test_polygon = new xserver.Polygon();
test_polygon.polygon = new xserver.PlainPolygon();
test_polygon.polygon.wrappedLinearRings = new xserver.PlainLinearRing[] { test_plainLinearRing };
xserver.Point point = new xserver.Point { point = new xserver.PlainPoint { x = 7.06654212202759, y = 41.3049992893457 } };
xserver.Geometry test_geometry = new xserver.Geometry {
description = "test_geometry",
id = 0,
geometry = test_polygon,
referencePoint = point
};
xserver.Geometries test_geometries = new xserver.Geometries();
test_geometries.wrappedGeometries = new xserver.Geometry[] { test_geometry };
test_geometries.wrappedOptions = test_geometryOptions;
xserver.GeometryLayer layer = new xserver.GeometryLayer {
name = "test_geometry_Layer",
drawPriority = 150,
visible = true,
wrappedGeometries = new xserver.Geometries[] { test_geometries },
objectInfos = xserver.ObjectInfoType.GEOMETRY
};
thanks in advance and Kind Regards
Daniele
c# WPF example of Geometry Layer
c# WPF example of Geometry Layer
Daniele Perella
Solution Engineer
PTV ITALIA Logistics
Solution Engineer
PTV ITALIA Logistics
- Oliver Heilig
- Posts: 160
- Joined: Tue May 13, 2014 12:10 pm
- Location: Karlsruhe, Germany
- Contact:
Re: c# WPF example of Geometry Layer
Hi Daniele,
this is a common misconception with xMapServer and xServer.NET. The xMapServer GeometryLayer is a part of the xMapServer WSDL. The GeometryLayer can be used to create static map images with custom content on the server-side. However if you use the xServer.NET widget, you typically render your custom content client-side. The client-side equivalent to the GeometryLayer is the xServer.NET ShapeLayer. So you should look at the xServer.NET ShapeLayer docs and samples.
Regards
Oliver
this is a common misconception with xMapServer and xServer.NET. The xMapServer GeometryLayer is a part of the xMapServer WSDL. The GeometryLayer can be used to create static map images with custom content on the server-side. However if you use the xServer.NET widget, you typically render your custom content client-side. The client-side equivalent to the GeometryLayer is the xServer.NET ShapeLayer. So you should look at the xServer.NET ShapeLayer docs and samples.
Regards
Oliver
Oliver Heilig
Chief Developer Logistic Services
PTV GROUP - Germany
https://github.com/oliverheilig/
Chief Developer Logistic Services
PTV GROUP - Germany
https://github.com/oliverheilig/
Re: c# WPF example of Geometry Layer
Hi Oliver,
thanks for this clarification. The shape layer is ok, the only problem is how to add an own shape layer, making it visible on the map but not in the control layer widget. is it possible?
Regards,
Daniele
thanks for this clarification. The shape layer is ok, the only problem is how to add an own shape layer, making it visible on the map but not in the control layer widget. is it possible?
Regards,
Daniele
Daniele Perella
Solution Engineer
PTV ITALIA Logistics
Solution Engineer
PTV ITALIA Logistics
- Oliver Heilig
- Posts: 160
- Joined: Tue May 13, 2014 12:10 pm
- Location: Karlsruhe, Germany
- Contact:
Re: c# WPF example of Geometry Layer
In this case the only option would be to add an underlying ShapeCanvas directly to the map, without using a layer. It is a bit hackish, but works
Code: Select all
// get the map view containing the content
var mapView = Ptv.XServer.Controls.Map.Tools.MapElementExtensions.FindChild<MapView>(Map);
// initialize shape canvas
var shapes = new ObservableCollection<FrameworkElement>();
var sc = new ShapeCanvas(mapView, shapes, "EPSG:4326", false);
Canvas.SetZIndex(sc, 100000000); // set it tomost
// add shape to shape collection
var pin = new Pin();
pin.Width = pin.Height = 30;
ShapeCanvas.SetLocation(pin, new System.Windows.Point(8.4, 49));
ShapeCanvas.SetAnchor(pin, LocationAnchor.RightBottom);
shapes.Add(pin);
Oliver Heilig
Chief Developer Logistic Services
PTV GROUP - Germany
https://github.com/oliverheilig/
Chief Developer Logistic Services
PTV GROUP - Germany
https://github.com/oliverheilig/
Re: c# WPF example of Geometry Layer
Great...it works like a charm.
Many Thanks,
Daniele
Many Thanks,
Daniele
Daniele Perella
Solution Engineer
PTV ITALIA Logistics
Solution Engineer
PTV ITALIA Logistics