Map center

Topics: General Topics
May 30, 2007 at 9:15 AM
Hi there, I've a OnClick event button that has to shift my map. I've done in this way

map.Center = new SharpMap.Geometries.Point(map.Center.X + 10, map.Center.Y + 10);
GenerateMap();

but the map doesn't move. The problem is that the map.Center value changes, but the image layout is lock.
Can anybody help me please?!
May 30, 2007 at 9:50 AM
Not sure what GenerateMap() does., but calling

MainMapImage.Map.Center = <coordinate>;
MainMapImage.Refresh();
does the trick, if you're set up like in the sample project.

If you're using a PictureBox, you can alternatively call
pictureBox.Image = map.GetMap();
May 30, 2007 at 10:23 AM
Edited May 30, 2007 at 10:27 AM

jo2007 wrote:
Not sure what GenerateMap() does., but calling

MainMapImage.Map.Center = <coordinate>;
MainMapImage.Refresh();
does the trick, if you're set up like in the sample project.

If you're using a PictureBox, you can alternatively call
pictureBox.Image = map.GetMap();




Thanks for your reply, but I don't Know why I can't apply refresh() method to mapImage. My Generate() method is the same of the example.
May 30, 2007 at 11:08 AM
My map center is a word coordinate. So in my case it's 48.xxxxxxxxx ,11.xxxxxxxxxxx
If you add 10 to both of them it really does make a big jump..

May 31, 2007 at 4:09 PM
Ehm...thanks! I've done in this way:

System.Drawing.PointF p = myMap.WorldToImage(new SharpMap.Geometries.Point(myMap.Center.X ,
myMap.Center.Y));
myMap.Center = myMap.ImageToWorld(new System.Drawing.PointF(p.X, p.Y+15));
GenerateMap();

Thanks a lot anyway.