Is it possible to have SharpMap without pan operation as a default one?

Topics: General Topics
Oct 3, 2006 at 7:35 AM


I am able to display the SharpMap and I am able place an object dynamically on the SharpMap.
The problem that I am facing here is whenever I click on the SharpMap the object is correctly placing whereever I am clicking on the SharpMap and at the sametime the SharpMap also changing its coordinates and displaying somewhere else
(i.e., whenever I am clicking on the SharpMap for placing an object, the pan operation also happening simultaneously).

Here, I am sending my program can u plz help me where I have to make the changes in my program to
stop the default operation of the pan in SharpMap.

private SharpMap.Map myMap;
protected void Page_Load(object sender, EventArgs e)
myMap = InitializeMap(new System.Drawing.Size((int)imgMap.Width.Value, (int)imgMap.Height.Value));

if (Page.IsPostBack)
//Page is post back. Restore center and zoom-values from viewstate
myMap.Center = (SharpMap.Geometries.Point)ViewState"mapCenter";
// myMap.Zoom = (double)ViewState"mapZoom";
//This is the initial view of the map. Zoom to the extents of the map:
//Save the current mapcenter and zoom in the viewstate
ViewState.Add("mapCenter", myMap.Center);
//Create the map

System.Drawing.PointF p1;

protected void imgMap_Click(object sender, ImageClickEventArgs e)
myMap.Center = myMap.ImageToWorld(new System.Drawing.Point(e.X, e.Y));

MultiPoint multiPoint = new MultiPoint();
SharpMap.Geometries.Point pointClicked = myMap.ImageToWorld(new System.Drawing.Point(e.X, e.Y));

SharpMap.Data.Providers.GeometryProvider geometryProvider = new SharpMap.Data.Providers.GeometryProvider(multiPoint);
SharpMap.Layers.VectorLayer laytheme1 = new SharpMap.Layers.VectorLayer("theme1");
laytheme1.DataSource = geometryProvider ;
laytheme1.MaxVisible =80;
laytheme1.SRID = 4326;
laytheme1.Enabled = true;
laytheme1.Style.Symbol = new Bitmap(HttpContext.Current.Server.MapPath(@"CAB2.JPG"));
laytheme1.Style.SymbolScale = 0.8f;


ViewState.Add("mapCenter", myMap.Center);
private SharpMap.Map InitializeMap(System.Drawing.Size outputsize)
//Initialize a new map of size 'imagesize'
SharpMap.Map map = new SharpMap.Map(outputsize);
SharpMap.Layers.VectorLayer layTheme1 = new SharpMap.Layers.VectorLayer("theme1");
// layTheme1.DataSource = new SharpMap.Data.Providers.ShapeFile(Server.MapPath(@"~\App_data\rivers.shp"), true);
layTheme1.DataSource = new SharpMap.Data.Providers.ShapeFile(Server.MapPath(@"~\App_data\theme1.shp"), true);
layTheme1.Style.Fill = new SolidBrush(Color.Brown);
layTheme1.Style.Line = new Pen(Color.Green, 1);
//layTheme1.Style.Line = new SharpMap.Geometries.Point(0,0);

return map;

private void CreateMap()
System.Drawing.Image img = myMap.GetMap();
string imgID = SharpMap.Web.Caching.InsertIntoCache(1, img);
imgMap.ImageUrl = "getmap.aspx?ID=" + HttpUtility.UrlEncode(imgID);