There are a coup of ways to accomplish the 1# and 3# questions. But first you need some definitions on each state to identify the region, and have an “offset table” for each region.
Then Create a OffsetInmemoryLayer inherent from InmemoryFeatureLayer .
public class OffsetInmemoryLayer : InMemoryFeatureLayer { private double xOffset = 0; private double yOffset = 0; private GeoCollection<Feature> originalFeatures = null ; public OffsetInmemoryLayer(double xOffset, double yOffset) { this.xOffset = xOffset; this.yOffset = yOffset; originalFeatures = new GeoCollection<Feature>(); }
InternalFeatures.Clear(); foreach (Feature feature in originalFeatures) { // TODO do the offset here InternalFeatures.Add(feature); }
base.DrawCore(canvas, labelsInAllLayers); } }
I have an idea for the 2# question, but the logic may be a little bit complicate.
You can create your own TextStyle inherents from TextStyle and overwrite the DrawCore method. In the override method, calculate the Area of the Text to see it is out of the state or not. If it is then try to make it smaller. if it is still out of the state, add some offsets on the label and draw a line or arrow point to it.
Thanks for your response. First I tried to use a shape file editor and edit the states.shp file and make a new shape file with the map appropriately set for the regions. But I got into a problem with it when the MapEngine was trimmming off some polygons for whatever reason and not drawing some of them .
I needed to get the map all in an A4 size paper for printing . So I thought of another alternative, I got an SVG file which has the image of the states and the territories sized appropriately. Is there a way for me to use this in a layer and process the map regions for adding a fill color . Or am I on my own for this kind of processing .
The pre-process data is also a good idea and I believe it enhances the performance as well.
Could you send us the code as well as the data to trim off the polygon you are using? That will help and speed up a lot to find the problem. Also I am doing some investigation on the SVG file to see what we can do on it.
After doing research I find the SVG data specification from w3.org/TR/SVG/ . We can create SVGFeatureSource inherent from FeatureSource to read data from SVG file, and SVGFeatureLayer inherent from FeatureLayer to render. Then you can easily specify the styles you want.
public class SVGFeatureSource : FeatureSource { private string pathFilename = "";
public SVGFeatureSource(string pathFilename) { this.pathFilename = pathFilename; }
protected override Collection<Feature> GetAllFeaturesCore(IEnumerable<string> returningColumnNames) { // Load features from the SVG file throw new NotImplementedException(); } }
public class SVGFeatureLayer : FeatureLayer { public SVGFeatureLayer(string pathFilename) { FeatureSource = new SVGFeatureSource(pathFilename ); } }