This project has moved. For the latest updates, please go here.

When center coordinate of VectorLayer is not within MapBox Bounding Box, layer is not displayed

Topics: SharpMap Project, SharpMap v0.9 / v1.x, WinForms Controls
Jul 11, 2013 at 10:41 PM

I am developing with SharpMap using WinForms. And I have a display issue. I will try to explain below.

I have a VectorLayer and it is set with a Image (Layer.Style.Symbol).
Basically, this is set as an overlay on top of a OSM Background Layer.

My issue is this:
When the center is changed, or the zoom is changed, and the center coordinates of VectorLayer (described above) is not within the Bounding Box of the MapBox, this is not displayed automatically by SharpMap.

If this is the current behavior of the library, is there a way to work around this issue?

Your feedback will be highly appreciated.

Jul 12, 2013 at 6:13 AM
Edited Jul 12, 2013 at 7:12 AM
You are right, the size of the symbol is not taken into account when computing the envelope of the layer.
You can override the VectorLayer class like this:
public class BufferedVectorLayer : VectorLayer
     * A bunch of constructor overloads may be necessary

    /// <summary>
    /// Gets or sets a value that is added to <see cref="SharpMap.Layers.VectorLayer.Envelope"/>
    /// </summary>
    public System.Drawing.SizeF EnvelopeBuffer { get; set; }

    public override GeoAPI.Geometries.Envelope Envelope 
            var res = base.Envelope;
            res.ExpandBy(2d*EnvelopeBuffer.Width, 2d*EnvelopeBuffer.Height);
            return res;
NOTE: The code has not seen a compiler and has not been tested.

Or you go for a solution as described in this thread.

Hth FObermaier
Jul 13, 2013 at 12:20 AM
Hello Hth FObermaier,

I will look into the suggestions you posted.

I will give you a feedback on this feedback as soon as possible.

Thank you very much.