I am trying to write a WPF application to render shapefile on a canvas without using any GIS SDK. Up to rendering its successfully completed. While trying to apply Scale transformation, I found that all the shapes on the canvas gets bigger while zoom in. In case of point features (shown as ellipse shape on canvas) and TextBlocks, the size should remains same, only the position should change relatively. Please guide me how to achieve this requirement.
For point features my code is as below:
private Geometry CreateEllipseGeometry(double size, Point centerPoint)
{
EllipseGeometry geom = new EllipseGeometry();
geom.RadiusX = size;
geom.RadiusY = size;
geom.Center = centerPoint;
geom.Transform = this.viewTransform;
return geom;
}
Here viewTransform is a transform group which has two children, one is scaletransform and another one is translatetransform.
I have found an article on this site (Prevent WPF TextBlock from expanding text due to LayoutTransform) that describes how to prevent textblock from expanding. the solution says to bind the inverse transform to the textblock.
Here my textblocks are created dynamically. So please tell me how to dynamically bind the inverse transform to a textblock.
I have done the exact job in WPF without using any API. in the case of point features you can set the Transform property of the point to the TranslateTransform (that is presumably contained in your viewTransform), so all point features move correctly as other features move when panning the map. but in the case of zooming I clear all the points and textblocks and recalculate their coordinates given the viewTransform.