I use the MWG 4.9.5 plugin in Labview API. In Labview some of the properties described in the documentation is missing, for unknown reasons, but maybe not supported from Labview. Finding the right property is already challenging in MWG, and not knowing if it is missing or not makes it even harder.
When loading a shape file, the “Land fill color” changes color in a random way which is annoying as I take screenshots for reports which then can have different and bad colors for the Land areas. I can set the Sea color with the backColor propery, but haven’t found the right property for Land color. If I was doing this in C# I could test some candidates, but if not available in Labview I will never know if it is possible.
So: Which property is changing the Land color or is it possible to lock this color to not change when map is loaded?
Another, option would be to loop through the shapes in the shapefile and assign colors to them somehow. Or maybe its better to assign categories to them. I can try something in C# and provide it here if you want. Just let me know.
Or maybe someone else can add something to the story above.
I have looked into my program and I did categorize all shapes, but for every shapefile again.
Now I was wondering, since the colors/categories do not change from shapefile to shapefile, or it is possible to define the categories once and apply them to the shapefiles in your program.
Maybe someone else can tell me?
For now, to answer bbend his question. Assuming that the program runs and that your shapefile is called “shapefile1”:
ShapefileCategory ct1 = shapefile1.Categories.Add("Cat1"); //Creating category
ShapefileCategory ct2 = shapefile1.Categories.Add("Cat2");
//etc.
bool set_bit = false; //Just a FOR loop as example to switch between a color after another. Could modify this to make it work with a database or something.
for (int i = 0; i < shapefile1.NumShapes; i++)
{
if (set_bit == false)
{
shapefile1.set_ShapeCategory(i, 0); //Adds certain shape (i) to a category
ct1.Expression = "[Type] = \"Cat1\""; //Add the expression.
set_bit = true; //Flipping the bit to true so it will take the ELSE statement next time.
}
else
{
shapefile1.set_ShapeCategory(i, 1);
ct2.Expression = "[Type] = \"Cat2\"";
set_bit = false;
}
}
ct1.DrawingOptions.FillColor = 240; //Assign the color red to this category by uint value.
ct2.DrawingOptions.FillColor = 0; //Assign the color black to this category by uint value.
//etc.
Thanks for the input! I will look into the code/examples you mention when I get back to work on tuesday.
As mentioned I use Labview and unfortunately very few use that plugin in LV so I don’t have any example code I can test out in my simple map client. To make things even more complicated there seems to be some lacking functionality in the LV component compared to C#, and so far only a few of the releases (4.7, 4.9.5…) has been compatible. So it’s been a struggle making things work, but there were not any good map plugins for LV when I made my client some years ago. The performance and functionallity has reached an acceptable level, especially after I found this forum where I get good answers for my usually basic questions.