I can create these shapes and add them to a InMemoryFeatureLayer. In fact I already do this.
After I add the shapes to the InMemoryFeatureLayer I add them to a LayerOverlay which I can go through and adjust each shapes position and rotation over time. This is funtioning so far but in trying to complete the request I have hit another wall.
I have several groups of shapes when combined represent a vehicle. The groups I have isolated in seperate InMemoryFeatureLayer's but I need to have more control over each shapes color. I also need to be able to alter the color over time to indicate an item in the group is in a different state.
It seems like this would be a snap but there are no brushes available in the basic shape. So
I am at a loss on how to do this. Each layer seems to only have global definitions to control a shapes
inMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Black), 3);
inMemoryLayer.ZoomLevelSet.ZoomLevel10.DefaultPointStyle.SymbolPen = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Green), 2);
I recall ValueStyle being mentioned but that is tied to a data column which is something I dont have. and how to attach each of these to a shape I have no idea and how to add these to a layer? In short I am a lost in how to combine these items outside of a shp file. The idea that I have to reference a column to an item to a style to a ?? Its not clear at all in how these work together to deliver an image to the screen. I dont even understand why there has to be a static layer then an InternalMemoryLayers added to that. To me layers are just that and usually represent Z order for drawing you add polygons at will to them then translate and rotate them. Help.. Thanks
I have quick reviewed all the past posts by you, I found that you already got many knowledge of MapSuite, you are on the way, I am sure you will play it very well soon. It seems that there are two questions in this post, “shapes” and “labels”. It tough to explain them in a few words, so if my answer is not very clear, please let me know.
First, about the Shapes: All shapes have one base class BaseShape, there are three kinds of shapes in MapSuite that we use three base classes PointBaseShape, LineBaseShape, AreaBaseShape represent them. Each shape is corresponding one Style, PointStyle, LineStyle, AreaStyle. The other Styles might just a wrapper of these three styles that work with all of three shapes. I think you are familiar with ValueStyle which works like this way. Each base shape has its own children classes, you can look at following diagram. For example, if you want to render EllipseShape, it’s inherited from AreaBaseShape, you need to set the AreaStyle to the certain zoom level.
Second, about the Labels: We render the labels by setting TextStyle, it’s a particular style not similar with the other three styles which I mentioned above deal with shapes, TextStyle is according to the column value which stored in Feature. What the Feature is? From the surface, it looks like the Shape, they can convert to each other easily, but Feature contains additional stuff ColumnValues which is a dictionary contains keys and values. you can image that the FeatureLayer is a data table, it defines a collection of FeatureSourceColumn represents the column definition for table structure, each Feature is a record, the key of ColumnValues should follow the ColumnName of FeatureSourceColumn, the value of ColmunValues is really the value which you want to show as the label on the map.
So when you add a feature to inMemoryLayer, you need assign the value to ColumnValues and set the TextStyle pass in the correct ColumnName, don’t forget adding the FeatureSourceColumn to inMemoryLayer.
I will try and write up a nice description but for now I would suggest you check out a couple of learning videos we have put together.
The key ones would be (in my suggested order)
1. Integrating Custom Data Formats (This will teach you about feature sources, features, and some layers) 2. Creating Custom Styles (this will teach you about styles and also about data columns etc) 3. Exploring Layers (this will teach you about layers in more detail and about layers without features)
David I am watching the videos now. Hope that will lead to an answer to my next question below.
James I dont see the relation between a Shape and a Style? I looked at the properties and methods for an AreaShape and did not find where the connection to a style is maintained. I will keep looking and watching video.
I can explain a little about the relationship between shape and style: Shape doesn’t has a style property, I think what James said means that if you want to see an AreaShape on the map control, you have to set the AreaStyle on the proper ZoomLevel. This is because shapes are organized in a layer, and the layer has the ability to render the shapes in it by different style in different ZoomLevels. So actually, the style connect to a specific ZoomLevel directly. For example, the current scale of your map control is in ZoomLevel01 and you want to see the AreaShapes in a specific layer, then you have to guarantee you have set the AreaStyle to ZoomLevel01 of the specific layer.
I don’t know what I said is clear enough, please let us know if there is still any confusions and questions.
Thank you for being interested in Map Suite products, and hope the learning vedios help you a lot.
Thanks everyone for the help. This would have been simpler if I could have the brushes and pens attached to the shapes but… with the addition of some CustomStyle’s I am able to do what I need to. At least it seems like it so far. Crossing my fingers its more downhill than up hill from here. (I always say that to make myself feel better) ;-)
Thanks again… I am getting there. Those videos and your information helped turn on some lights although I kind of understand a FeatureSource I am not sure why I would use it. Adding features to a layer seems more simplistic. Least to me. Anyway… Thanks Bob
Well more problems. I add several polygons to the inMemoryLayer. OK no problem but the text style thats attached to the is being covered by the polygons. (it worked earlier when they were hollow in the middle) How do i make sure the label is on top? I also cant change the text position to anywhere outside the polygons which would be handy.
This is in my custom TextStyle
public CustomTextStyle(string id) { TS = new TextStyle(); TS.PointPlacement = PointPlacement.LowerLeft; TS.OverlappingRule = LabelOverlappingRule.AllowOverlapping; TS.DuplicateRule = LabelDuplicateRule.NoDuplicateLabels; TS.Font = new GeoFont("Arial Black", 10, DrawingFontStyles.Regular); TS.TextSolidBrush = new GeoSolidBrush(GeoColor.StandardColors.WhiteSmoke); TS.Name = ID + "_TXT"; }
When I draw
protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers) { foreach (Feature feature in features) { // I have tried to offset it // TS.YOffsetInPixel = 500; // and altering the TS.DrawingLevel = DrawingLevel.LevelFour; // how do I make this text end up on top?
One more item on my list. Keeping the ZOrder correct for a shape. I have several shapes in a layer. About 6 to 8 unique shapes. I noticed that the ZOrder of the shapes can change over time. For example I have a rectangle1 below and rectangle2 above and they overlap. (which is what I want). Sometimes it rectangle 1 will draw on top of rectangle 2 for no apparent reason. How do you keep Zorder of shapes.
In both custom systles the labelsInThisLayer, labelsInAllLayers are zero… Does this stop the text from drawing? Before when I added a deftault textstyle it worked just fine ???
Thank you for your code snippet that is very helpful to find your problem.
We use drawingLevel to control the ZOrder, and we set it to DrawingLevel.LabelLevel in the constructor of TextStyle that can keep the label always on top. From your code and you create a custom text style inherit from TextStyle but you don’t call the base(), so I guess you make the DrawingLevel wrong in your style. You can set it to DrawingLevel.LabelLevel manually if you want to draw it on top, or just call base() as following code:
public class CustomTextStyle : TextStyle { public CustomTextStyle() : this(string.Empty) { }
public CustomTextStyle(string id) : base() { // your own code. } }
Please remember call the base() when you extend our classes, otherwise you might change our logic behind.
I made change to the way I handle the text and everything is working great.
What I did not understand (this was total oversight and not being able to connect the dots) is that when you OverRide DrawCore the feature is a single polygon and the label is drawn according to the location of that polygon. Since I have several features per layer it was totally messing up my text output. In short I am getting a much better handle on controling this tool for our purpose.
I am glad it’s working with you. And you should thank yourself :) , because you did a lot of research before you ask questions, so you can provide enough information that can easy find your problem, otherwise you can not get the solution in time.