Uhmmm, I think I found the problem.
I use this code to display a point in my map
SharpMap.Geometries.Point point = new SharpMap.Geometries.Point(12, 12);
SharpMap.Data.Providers.GeometryProvider provider = new SharpMap.Data.Providers.GeometryProvider(point);
SharpMap.Layers.VectorLayer layer = new SharpMap.Layers.VectorLayer("point", provider);
layer.Style.Point.Type = SharpMap.Styles.VectorStyle.PointStyle.TypeEnum.Vector;
layer.Style.Point.Vector.Type = SharpMap.Styles.VectorStyle.PointStyle.VectorPointStyle.TypeEnum.Circle;
layer.Enabled = true;
layer.MinVisible = double.Epsilon;
layer.Style.Enabled = true;
layer.Style.Fill = Brushes.Red;
mapBox.Map.Layers.Add(layer);
mapBox.Map.Center = point;
mapBox.Refresh();
Note that I use the PointStyle patch from Issue Tracker section, but the problem is not related to 0.9 point style implementation.
The problem is that having a single point geometry and calling ZoomToExtents means that Zoom wil be set to 0, have a look at the ZoomToExtents code
public void ZoomToExtents()
{
this.ZoomToBox(this.GetExtents());
}
public void ZoomToBox(SharpMap.Geometries.BoundingBox bbox)
{
this._Zoom = bbox.Width; //Set the private center value so we only fire one MapOnViewChange event
if (this.Envelope.Height < bbox.Height)
this._Zoom *= bbox.Height / this.Envelope.Height;
this.Center = bbox.GetCentroid();
}
As you can see if the only object to render is a point, zoom is set to 0.
This means that nothing will be displayed, since having zoom 0 prevents any object from being rendered, as you can see in GetMap function in Map.cs
Now, if zoom is set to 0, and your point min zoom is 0.5 (like in your example) obviusly the point will not be rendered... moreover if you set minZoom to 0 again the point will not be rendered, since the current zoom value has to be strictly greater than minZoom... if you set it to a negative value, in my case (with point styles, but I think it's the same with standard source code) render cycle throws an exception while trying to render the symbol (a path)...
So, to view correctly your drawn points you should use the proper zoom without calling ZoomToBox/ZoomToExtents, or modify ZoomToBox like this:
public void ZoomToBox(SharpMap.Geometries.BoundingBox bbox)
{
this._Zoom = bbox.Width; //Set the private center value so we only fire one MapOnViewChange event
if (this.Envelope.Height < bbox.Height)
this._Zoom *= bbox.Height / this.Envelope.Height;
if(_Zoom=0)
_Zoom=1;
this.Center = bbox.GetCentroid();
}
This way if the zoom value will be set to 0 (it happens when only a point geometry is present), automatically will be restored to 1, allowing you to see the point... btw I would advice about not changing the ZoomToBox function, and simply put another layer (as a background layer or such) to avoid the problem :P
Thanks Blade, I think i'll use the PointStyle patch, afterall i believe it's much quicker than show an image..
btw, you're using mapbox for refreshing map for windows form.
How about web form, i'm using ajaxMap, how to refresh them after i finnaly adding point to my map ?
Yes, I'm developing a desktop application, so I use MapBox... I don't know very much about web developing, so I haven't played with AjaxMap control, but I belive the examples show how to refresh a map like using the Refresh method, obviusly it will be a remote call... unfortunally I can't be more precise, since this is not really somethig I'm good at ^^