This project is read-only.

MapWinGeoProc.ScaleTools.ExtentFromScale displays incorrectly

Oct 18, 2012 at 3:47 PM

 

Hello friends, 

I am using linear scale in the form Scale 1 : 50000. I expect the map to enlarge but it returns very small. Below is my code. Please can someone identify my error. I am new to MapWinGis.ocx.


public void SetMapScale() 

SetMapScale ms = new SetMapScale(); 
ms.txtCurrentScale.Text = m_LinearScale; 
MapWinGIS.Extents ext = new MapWinGIS.Extents(); 
ext = (MapWinGIS.Extents)axMap1.Extents; 
MapWinGIS.Point centrePoint = new MapWinGIS.Point(); 
double pixXmin = 0, pixXmax = 0, pixYmin = 0, pixYmax = 0; 
this.axMap1.ProjToPixel(ext.xMin, ext.yMin, ref pixXmin, ref pixYmin); 
this.axMap1.ProjToPixel(ext.xMax, ext.yMax, ref pixXmax, ref pixYmax); 
centrePoint.x = (pixXmax + pixXmin) / 2.0; 
centrePoint.y = (pixYmax + pixYmin) / 2.0; 
double mapWidth = 0, mapHeight = 0; 
this.axMap1.ProjToPixel(axMap1.Width, axMap1.Height, ref mapWidth, ref mapHeight); 
int w = (int)(mapWidth); 
int h = (int)(mapHeight); 
if (ms.ShowDialog() == DialogResult.OK)// select scale 

int scale = (int)ms.m_MapScale; 

string mapUnit ="meters"; 
ext = MapWinGeoProc.ScaleTools.ExtentFromScale(scale, centrePoint, mapUnit, w, h); 
axMap1.Extents = ext; 
axMap1.Refresh(); 

}

 

 

Oct 22, 2012 at 11:57 AM

Can't you use the CurrentScale property of axMap1: http://www.mapwindow.org/documentation/mapwingis4.8/class_ax_map.html#a3746cb2f2d816f7ae6b910679b142301

It looks to me much easier.

--
Paul

Oct 22, 2012 at 2:33 PM

Thanks Paul, for assisting me. It looks so easy as you said. 

Kehinde