I need to know about feature style.
Is it has one style by one layer ?
(I think it Yes)
(I will be confirm to boss. He think it has one style by one feature because tabfile it has one style by one feature)
Thnak you.
I need to know about feature style.
Is it has one style by one layer ?
(I think it Yes)
(I will be confirm to boss. He think it has one style by one feature because tabfile it has one style by one feature)
Thnak you.
Sumeth,
You can use as many styles as you want for any vector based layers such as shapefiles or tab files using the CustomStyles.Add function. See the code below, this is a variation of the sample "Load TabFileFeatureLayer" from the How Do I samples and you can see how I add two Styles. I could add as many styles as I desire.
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.ThreadingMode = MapThreadingMode.SingleThreaded;
WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsDesktopOverlay();
winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);
winformsMap1.CurrentExtent = new RectangleShape(-96.51477, 30.759543, -94.355788, 28.910652);
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
TabFeatureLayer tabLayer = new TabFeatureLayer(@"..\..\SampleData\Data\HoustonMuniBdySamp_Boundary.TAB");
//Adding two style to the tab file.
AreaStyle areaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(100, GeoColor.SimpleColors.Green), GeoColor.SimpleColors.Green);
AreaStyle areaStyle2 = AreaStyles.CreateHatchStyle(GeoHatchStyle.LargeConfetti, GeoColor.StandardColors.Red, GeoColor.StandardColors.Transparent);
tabLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(areaStyle);
tabLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(areaStyle2);
tabLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.Layers.Add("WorldLayer", tabLayer);
winformsMap1.Overlays.Add(staticOverlay);
winformsMap1.Refresh();
Sorry for my english.
I think you misuntderstand me.
your code is add more style to layer. It not add style to feature.
see at below picture
example: I have layer "thailand region". the feature are have style by itself.
if I not use classbreakstyle. How do I?
I need to apply with draw features and then insert to InmemoryFeatureLayer with different style.
Can I add feature more than 1 feature to 1 layer with different style?(example. Add 3 feature with 3 style to 1Layer )
This My concept :
-keep style on one table with json format(or keep more properties of Mapsuite style). (The table is keep style and ID)
-when I add style , I should have save ID style to feature on layer.
- I will create class for create ClassBreakStyle with table style in dababase.
-On next load, I will add Layer with class break style
Do you have other solution?
Sumeth,
I am still not completely sure I understand what you are asking but it sounds like you want to color the different features based on some value in the database. For that, you will need to use ValueStyle where you set the column to be used and for each value for that column, you have a different style. In the "How Do I" samples, under the category "Styles", we have the sample "Draw Features Based On Values" where you have the cities displayed with different styles based on their population rank, "1", "2" or "3". Here we are using a point based layer but you could do the same think with line or polygon based layer as it is in your case for Thailand provinces.
If I still don't understand what you are asking, I suggest you look at the samples under the "Styles" category and you can tell me of all those samples which one is the closest to what you are trying to do. wiki.thinkgeo.com/wiki/Map_Suite_We...es_Samples.
Thank you.
Sumeth, I am still not completely sure I understand what you are asking but it sounds like you want to color the different features based on some value in the database. For that, you will need to use ValueStyle where you set the column to be used and for each value for that column. Posted By Val on 12-20-2011 10:49 AM
That right. I think it solution for solve this issue.
But I don’t know, Is it best solution?
If I have more feature and more style, I think It make low performace because that use foreach loop.
If you better solution , please tell me.
I have question. Do you have picture style of your default style ? (I mean picture PointStyles.Capital1 and other style with All shape)
If you have not, I will be run and caputre and use it to make menu for user select.
Thank you very much.
sorry for my english again.
Sumeth,
Can you send us your layer (tabfile I believe) of Thailand so that we have the exact thing as you are working with? That will give us a better idea of what you are doing exactely. Also, can you try to explain to us one more time how you want to display your data? If you don't feel comfortable attaching your file to this post, you can send it to support@thinkgeo.com. If the file is too big to be attached, we can set you up with FTP.
Regarding the default styles, you can find their visual representations at gis.thinkgeo.com/Support/APIDocumen...fault.aspx .
Thank you.
I can’t send layer to you because it’s data of company.
Now, I use MSSQL2008 Layer.
I want add feature with style.
exsample :
1 feature = 1 style.
10 feature = 10 style.
my customer want to add feature and style to database.
and I don’t know how to render data to map on next time.
I try to find solution for solve that.
Above post is my concept.
1. add column styleID for layer
2. create table styleDetail for keep style (JSON format or specific style column i.e. fill,border,borderwidth)
3. create class for add ValueStyle (The class use for load style detail from database and then use foreach add valuestyle)
when map load I will use class at line 3 for create ValueStyle and add to layer.
I will try to do it on tomorrow.
thank you for try to understand me.
Sumeth,
Thank you for your additional information. I will ask assistance to Ben from the Development Team because he is more knowledgeable than me in MSSQL2008. We will take off this week end for the holidays so early next week you should get a response.
thank you very much.
And Happy X’mas :)
Hi Sumeth,
I think there are three issues in all.
First of all, the ValueStyle is the best approach for your scenario. If your data is too big, I think there is a change to do to optimize it on the zoom levels part. For example, if we draw 1,000,000 features on zoom level 1, which means you might draw 1,000,000 featues in a 256*256 tile (default size). You know this 256*256 tile has only 65536 pixel; if each pixel draws one feature, this tile will fill with colors. So I recommend to arrange a better zoom level strategy such as in lower zoom level, we draw higher priority features; while zooms in deeper and deeper, we draws more and more detail. This will enhance your performance better.
For your second issue, I think you want to draw a thumbernail for each default styles right? Every style has a "DrawSample" method, it allows to draw the style with a specific GdiPlusGeoCanvas. If there is any misunderstanding, please let us know. Here is the code.
public static Bitmap GetThumbernail(Style style, int width = 64, int height = 64)
{
Bitmap bitmap = new Bitmap(width, height);
GdiPlusGeoCanvas geoCanvas = new GdiPlusGeoCanvas();
geoCanvas.BeginDrawing(bitmap, new RectangleShape(-180, 90, 180, -90), GeographyUnit.DecimalDegree);
style.DrawSample(geoCanvas);
geoCanvas.EndDrawing();
return bitmap;
}
For the third question:
We can use BinaryFormatter to serialize the style object to bynary, when you want to load it back, just deserialize it back to style and add to the CustomStyles collection in ZoomLevel. It's not difficulte.
Please let me know if there is any misunderstanding.
Thanks,
Chen