ImageToWorld() public method

Converts a point from image coordinates to world coordinates based on the current zoom, center and mapsize.
public ImageToWorld ( System p ) : SharpMap.Geometries.Point
p System Point in image coordinates
return SharpMap.Geometries.Point
Exemplo n.º 1
0
 protected void imgMap_Click(object sender, ImageClickEventArgs e)
 {
     //Set center of the map to where the client clicked
     myMap.Center = myMap.ImageToWorld(new System.Drawing.Point(e.X, e.Y));
     //Set zoom value if any of the zoom tools were selected
     if (rblMapTools.SelectedValue == "0")         //Zoom in
     {
         myMap.Zoom = myMap.Zoom * 0.5;
     }
     else if (rblMapTools.SelectedValue == "1")         //Zoom out
     {
         myMap.Zoom = myMap.Zoom * 2;
     }
     //Create the map
     GenerateMap();
 }
Exemplo n.º 2
0
	protected void imgMap_Click(object sender, ImageClickEventArgs e)
	{
		//Set center of the map to where the client clicked
		//We set up a simple empty map so we can use the ImageToWorld() method for easy conversion from Image to World coordinates
		SharpMap.Map myMap = new SharpMap.Map(new Size(Convert.ToInt32(imgMap.Width.Value), Convert.ToInt32(imgMap.Height.Value)));
		myMap.Center = Center; myMap.Zoom = Zoom;
		Center = myMap.ImageToWorld(new System.Drawing.Point(e.X, e.Y));

		//Set zoom value if any of the zoom tools were selected
		if (rblMapTools.SelectedValue == "0") //Zoom in
			Zoom = Zoom * 0.5;
		else if (rblMapTools.SelectedValue == "1") //Zoom out
			Zoom = Zoom * 2;
		//Create the map
		GenerateMap();
	}
Exemplo n.º 3
0
        public void ShowMap(Map map)
        {
            MapControl.Map = map;

            map.ZoomToExtents();

            MapControl.MouseMove += delegate(object sender, MouseEventArgs e)
                                        {
                                            var point = map.ImageToWorld(new PointF(e.X, e.Y));
                                            coordinateLabel.Text = string.Format("{0}:{1}", point.X, point.Y);
                                        };

            WindowsFormsTestHelper.ShowModal(this);

            map.Dispose();
        }
Exemplo n.º 4
0
    protected void imgMap_Click(object sender, ImageClickEventArgs e)
    {
        //Set center of the map to where the client clicked
        //We set up a simple empty map so we can use the ImageToWorld() method for easy conversion from Image to World coordinates
        SharpMap.Map myMap = new SharpMap.Map(new Size(Convert.ToInt32(imgMap.Width.Value), Convert.ToInt32(imgMap.Height.Value)));
        myMap.Center = Center; myMap.Zoom = Zoom;
        Center       = myMap.ImageToWorld(new System.Drawing.Point(e.X, e.Y));

        //Set zoom value if any of the zoom tools were selected
        if (rblMapTools.SelectedValue == "0")         //Zoom in
        {
            Zoom = Zoom * 0.5;
        }
        else if (rblMapTools.SelectedValue == "1")         //Zoom out
        {
            Zoom = Zoom * 2;
        }
        //Create the map
        GenerateMap();
    }
Exemplo n.º 5
0
 public void ImageToWorld_DefaultMap_ReturnValue()
 {
     Map map = new Map(new Size(500, 200));
     map.Center = new Point(23, 34);
     map.Zoom = 1000;
     Point p = map.ImageToWorld(new PointF(242.5f, 92));
     Assert.AreEqual(new Point(8, 50), p);
 }
Exemplo n.º 6
0
 public void ImageToWorld()
 {
     Map map = new Map(new Size(1000, 500));
     map.Zoom = 360;
     map.Center = new Point(0, 0);
     Assert.AreEqual(new Point(0, 0), map.ImageToWorld(new PointF(500, 250)));
     Assert.AreEqual(new Point(-180, 90), map.ImageToWorld(new PointF(0, 0)));
     Assert.AreEqual(new Point(-180, -90), map.ImageToWorld(new PointF(0, 500)));
     Assert.AreEqual(new Point(180, 90), map.ImageToWorld(new PointF(1000, 0)));
     Assert.AreEqual(new Point(180, -90), map.ImageToWorld(new PointF(1000, 500)));
 }
Exemplo n.º 7
0
 public void Draging(Point Pos)
 {
     Pos         = new Point(Pos.X * -1, Pos.Y * -1);
     _Map.Center = _Map.ImageToWorld(new Point(_Map.Size.Width / 2 + Pos.X, _Map.Size.Height / 2 + Pos.Y));
 }
Exemplo n.º 8
0
        private BoundingBox RectToEnvelope(RectangleF rect)
        {
            var p1          = new PointF(rect.Left, rect.Top);
            var p2          = new PointF(rect.Right, rect.Bottom);
            var topleft     = _Map.ImageToWorld(p1);
            var bottomright = _Map.ImageToWorld(p2);

            return(new BoundingBox(topleft.X, bottomright.Y, bottomright.X, topleft.Y));
        }