This is a migrated thread and some comments may be shown as answers.

VisualizationLayer and StrokeDashArray

1 Answer 16 Views
Map
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 1
Dennis asked on 29 Jul 2014, 10:26 AM
Hello,

I am evaluating RadMap (silverlight).  In my application I would like to add a lot of custom shapes to some map layers.  To test this I have added a VisualizationLayer and proceeded to add about 1000 rectangle object.  Very good.  Now I notice that I can apply a MapShapeFill object directly on the layer and if none of the rectangles have the shape fill specified, it uses the layer default.  Since I think all my shapes in a layer will have the same style this is useful.  Now I wanted to test out the dash stroke styles as this is quite important to me and I notice that if I added a MapShapeFill to my rectangle with a StrokeDashArray all is well and my rectangles draw correctly, but if I add a StrokeDashArray to the MapShapeFill attached to the layer I get an exception (the famous "The value does not fall within the expected range" exception).

I must add all my layers and geographic elements in code and as there may be a lot of them, I would prefer to do this in the most efficient way.  Are there any ways around the error (or is it even important to use a layer level FillShape rather than an element level FillShape).  Here is the test code I am using (working version commented out).

var v2 = map.Items [1] as VisualizationLayer;
v2.Name = Guid.NewGuid ( ).ToString ( );
v2.ShapeFill = new MapShapeFill ( ) {
Fill = new SolidColorBrush (Color.FromArgb (32, 0, 240, 255)),
  Stroke = new SolidColorBrush (Colors.Red),
  StrokeThickness = 2,
  StrokeDashArray = new DoubleCollection ( ) { 4, 2, 2, 2 }
  };
double start = -0.000025 * 33.0;
for (int i = 0; i < 33; i++) {
  for (int j = 0; j < 33; j++) {
    double x = start + 0.000075 * (double) i; 
    double y = start + 0.000075 * (double) j;
    var rect = new RectangleData ( ) {
      Location = new Location (this.DefaultLatitude + y, this.DefaultLongitude + x),
      Height = 0.00005,
      Width = 0.00005,
      //ShapeFill = new MapShapeFill ( ) {
        // Fill = new SolidColorBrush (Color.FromArgb (32, 0, 240, 255)),
        // Stroke = new SolidColorBrush (Colors.Red),
        // StrokeThickness = 2,
        // StrokeDashArray = new DoubleCollection ( ) { 4, 2, 2, 2 }
        //}
      };
      v2.Items.Add (rect);
    }
  }


1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 30 Jul 2014, 05:55 AM
Hi Dennis,

We have logged the issue in our feedback portal to fix the problem in future versions of RadMap.
Currently as workaround I would recommend to use the MapShapeData.SerializedShapeFill property instead of using ShapeFill property on the layer level. It does not require to create the MapShapeFill instance for each shape. The sample code is below.

MapShapeDataFill shapeDataFill = new MapShapeDataFill()
{
    FillColor = Color.FromArgb(32, 0, 240, 255),
    StrokeColor = Colors.Red,
    StrokeThickness = 2,
    StrokeDashArray = new double[] { 4, 2, 2, 2 }
};
 
double start = -0.000025 * 33.0;
for (int i = 0; i < 33; i++)
{
    for (int j = 0; j < 33; j++)
    {
        double x = start + 0.000075 * (double)i;
        double y = start + 0.000075 * (double)j;
        var rect = new RectangleData()
        {
            Location = new Location(this.DefaultLatitude + y, this.DefaultLongitude + x),
            Height = 0.00005,
            Width = 0.00005,
            SerializedShapeFill = shapeDataFill
        };
        v2.Items.Add(rect);
    }
}

Regards,
Andrey Murzov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Map
Asked by
Dennis
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or