hi,
i use "ValueStyle" to grouping polygons, this feature group by color
how can i load image instead AreaStyle ( load image in polygons instead color with areastyle )
thanks
Set image in ValueStyle
Hi Alireza,
I think this sample should be helpful for draw an image in area style:
wiki.thinkgeo.com/wiki/_media/file/ServicesEditionSample_ImageStyle_CS_120209.zip
Regards,
Don
and another question
how can i use this to AreaStyle??
my c# code is:
Collection<geocolor> colorsInFamily = GeoColor.GetColorsInHueFamily(GeoColor.StandardColors.BlueViolet, 5);
ValueStyle valueStyle = new ValueStyle();
valueStyle.ColumnName = "ID";
valueStyle.ValueItems.Add(new ValueItem("1", AreaStyles.WaterIntermittent1));
valueStyle.ValueItems.Add(new ValueItem("29", new AreaStyle(new GeoSolidBrush(colorsInFamily[1]))));
//// how can i use imagestyle for this id?? => //// valueStyle.ValueItems.Add(new ValueItem("2",</geocolor>
Hi Alireza,
I think you should override the DrawCore method of AreaStyle. The code just like following:
public class ImageAreaStyle : AreaStyle
{
private GeoImage geoImage = null;
public ImageAreaStyle(GeoImage geoImage)
{
this.geoImage = geoImage;
}
protected override void DrawCore(IEnumerable<
Feature
> features, GeoCanvas canvas, Collection<
SimpleCandidate
> labelsInThisLayer, Collection<
SimpleCandidate
> labelsInAllLayers)
{
// Loop through all of the features being passed in to draw.
foreach (Feature feature in features)
{
WellKnownType shapeWellKnownType = feature.GetWellKnownType();
if (shapeWellKnownType == WellKnownType.Polygon)
{
PolygonShape polygonShape = new PolygonShape(feature.GetWellKnownBinary());
canvas.DrawArea(polygonShape, new GeoTextureBrush(geoImage), DrawingLevel.LevelOne);
}
else if (shapeWellKnownType == WellKnownType.Multipolygon)
{
MultipolygonShape multiPolygonShape = new MultipolygonShape(feature.GetWellKnownBinary());
canvas.DrawArea(multiPolygonShape, new GeoTextureBrush(geoImage), DrawingLevel.LevelOne);
}
}
}
}
And use the following code to apply it to the ValueItem:
valueStyle.ValueItems.Add(new ValueItem("2", new ImageAreaStyle(new GeoImage(imagePath))));
Thanks,
Peter
Mucho Mucho Mucho Gracias
how can i set Alpha for this pictures?
Thanks
Hi Alireza,
Please try changing the Opacity property of GeoImage the default value is 1.0f.
NOTE: This property is declared only in the Development version.
Thanks,
Peter