Zoom setting for a small map

Apr 5, 2009 at 12:26 PM
I would like to use Sharpmap to display the map of my City (Hanoi), But I don't know the how to set the initial-setting for the shapmap.

SharpMap.Map map = new SharpMap.Map();

            //Set up the countries layer
            SharpMap.Layers.VectorLayer road = new SharpMap.Layers.VectorLayer("Hanoiroad");
            road.Style.EnableOutline = true;

            //Set the datasource to a shapefile in the App_data folder
            road.DataSource = new SharpMap.Data.Providers.CustomData("HaNoi.dat");
            //Set the polygons to have a black outline
            road.Style.Outline = System.Drawing.Pens.Black;
            road.Style.EnableOutline = true;
            road.SRID = 4326;

            //limit the zoom to 360 degrees width
            map.MaximumZoom = 360;
            map.Zoom = 360;
            map.Center = new SharpMap.Geometries.Point(21, 105);
            //map.Center = new SharpMap.Geometries.Point(0, 0);
            return map;

The center of HN in Lat, Lon is (21, 105). Please give a suggestion to display the map of HN.

Thank you.

Apr 6, 2009 at 1:17 PM
First, you need a control that displays your Map.  You need to declare a MapBox and add it to your form.  A simple way to center the display to your layers is to call map.ZoomToExtents() and then refresh your mapbox (mapBox.Refresh()).