Hossein,
I extented the class ImageStyle so that it can handle having an Image for representing line based feature. You can see the result in the screen shot below. I use an actual image of a pavement to draw my streets. Keep in mind that this is a fairly intensive operation and that ImageStyle should be limited to the lower zoom levels to avoid performance issues. Also you can see the new code for ImageStyle.
wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
ShapeFileFeatureLayer streetLayer = new ShapeFileFeatureLayer(@"C:\ThinkGeo\Support\MapData\Austinstreets.shp");
ImageStyle imageStyle = new ImageStyle(new GeoImage(@"C:\ThinkGeo\Support\Posts\10037\Pavement.png"), 5);
TextStyle textStyle = new TextStyle("FENAME", new GeoFont("Arial", 10), new GeoSolidBrush(GeoColor.StandardColors.Maroon));
textStyle.HaloPen = new GeoPen(GeoColor.StandardColors.White, 3);
streetLayer.ZoomLevelSet.ZoomLevel18.CustomStyles.Add(imageStyle);
streetLayer.ZoomLevelSet.ZoomLevel18.CustomStyles.Add(textStyle);
streetLayer.ZoomLevelSet.ZoomLevel18.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
streetLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(new LineStyle(new GeoPen(GeoColor.StandardColors.DarkGray,3)));
streetLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level17;
LayerOverlay layerOverlay = new LayerOverlay();
layerOverlay.TileType = TileType.SingleTile;
layerOverlay.Layers.Add(streetLayer);
wpfMap1.Overlays.Add(layerOverlay);
streetLayer.Open();
wpfMap1.CurrentExtent = new RectangleShape(-97.7231, 30.2752, -97.7212, 30.2740);
streetLayer.Close();
class ImageStyle : Style
{
private GeoImage geoImage = null;
private int lineWidth;
public ImageStyle(GeoImage geoImage, int lineWidth)
{
this.geoImage = geoImage;
this.lineWidth = lineWidth;
}
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);
}
else if (shapeWellKnownType == WellKnownType.Line)
{
LineShape lineShape = new LineShape(feature.GetWellKnownBinary());
double worldDistance = ExtentHelper.GetWorldDistanceBetweenTwoScreenPoints(canvas.CurrentWorldExtent, new ScreenPointF(0,0),new ScreenPointF(lineWidth,0),canvas.Width,
canvas.Height,canvas.MapUnit,DistanceUnit.Meter);
MultipolygonShape multiPolygonShapeBuffer = lineShape.Buffer(worldDistance, canvas.MapUnit, DistanceUnit.Meter);
canvas.DrawArea(multiPolygonShapeBuffer, new GeoTextureBrush(geoImage), DrawingLevel.LevelOne);
}
else if (shapeWellKnownType == WellKnownType.Multiline)
{
MultilineShape multilineShape = new MultilineShape(feature.GetWellKnownBinary());
double worldDistance = ExtentHelper.GetWorldDistanceBetweenTwoScreenPoints(canvas.CurrentWorldExtent, new ScreenPointF(0, 0), new ScreenPointF(lineWidth, 0), canvas.Width,
canvas.Height, canvas.MapUnit, DistanceUnit.Meter);
MultipolygonShape multiPolygonShapeBuffer = multilineShape.Buffer(worldDistance, canvas.MapUnit, DistanceUnit.Meter);
canvas.DrawArea(multiPolygonShapeBuffer, new GeoTextureBrush(geoImage), DrawingLevel.LevelOne);
}
}
}
}