ThinkGeo.com    |     Documentation    |     Premium Support

Map events and Projection convertion

Hi,


There are some map events like TrackLineDraw, TrackCircleDraw , SelectMapShapes  etc in Map Suite 2.0, can't find them in Map Suite 3.0. Are they not supported any more?


When the mouse moves on the map, I want to display the world coordinates at the status bar, how to convert the screen coordinates to world coordinates?


In ver 2.0, I created following class to convert the Geodetic projection coordinates to Mercator projection,  how to do this in version 3.0?


 



 


Class GeodeticToMercatorImplements IProjection ''' 
X-coordinate

 


''' 
Y-coordinate

 


''' <returns></returns>After transformation coordinate

 


 


Public Function ProjectPoint(ByVal X As Double, ByVal Y As Double) As PointR Implements IProjection.ProjectPoint' Create a MollweidProj.

 


 


 


 


Dim MercatorProj As MercatorProj = New MercatorProj()Dim Easting As Double = 0Dim Northing As Double = 0' Convert.

MercatorProj.ConvertGeodeticToMercator(Y, X, Easting, Northing)


ProjectPoint =


 


End


New PointR(Easting, Northing)End Function Class

 


 


 



 



Public



Rose, 



We don't have the similar events to TrackLineDraw or TrackCircleDraw in current 3.0 Beta. You need to implement it yourself by overwriting the MouseMove event. We don't have the similar one for SelectMapShapes also, as we don't have MapShapes in 3.0 any more. You can still implement this function by overwriting the Mouse Click event and get the nearest shape through spatial query. By the way, in 3.0, you need to change the track mode in EditOverlay. For example, here is how to set the map to TrackCircle mode. 


winformsMap1.EditOverlay.TrackMode = TrackMode.Circle

We have a static class ExtentHelper for all the coordinate transformation stuff. You can use ExtentHelper.ToWorldCoordinate() to change a screen coordinate to a world coordinate. Check ExtentHelper for more transformation methods. 



Projection part changes a lot from 2.0. Now we are using the Srid number to do the projection conversion. So for example, you want to show a Geodetic layer within Mercator projection, here is you need to do.  

1, Check the Srid number for both Geodetic and Mercator.  Geodetic is 4326, for Mercator please check it in the documentation (C:\Program Files\ThinkGeo\Map Suite Desktop Evaluation Edition 3.0 (BETA)\Documentation\Projections) . For example, in EPSG.rtf, I found the “New Zealand Transverse Mercator” with the Srid 1229. 

2, Create a Proj4Projection object with the 2 srid numbers. 


Proj4Projection proj4 = new Proj4Projection(4326, 1229)

3, Set the proj4 project to layer.FeatureSource, don't forget to set the map's current extent. Code will be like this. 


Dim proj4 As New Proj4Projection(4326, 1229)
newZealandLayer.FeatureSource.Projection = proj4
newZealandLayer.Open()
winformsMap1.CurrentExtent = newZealandLayer.GetBoundingBox()
newZealandLayer.Close()

Also, you can create your projection by inheriting the “Projection” class and override a couple methods, just like what need to do in 2.0. You can even use the 2.0 projection objects by referencing the MapSuiteCommon.dll. 



Let me know for more queries. 



Thanks, 



Ben



Ben:


Thank you for all your replies! They help me a lot. I am moving forward on the way to upgrade to Map Suite ver. 3.0!


Do you have any examples that implement the TrackLineDraw event  in ver 3.0.  After I set the  EditOverlay.TrackMode to TrackModel.Line, I can see the line is drawn on the map. How  to retrieve the line geometry information and save it in a LineShape, so I can do other spatial operations using the LineShape with other features in my Feature Layer? One of the reasons we chose Map Suite Desktop instead of Map Suite Engine is that the Desktop has more ready-to-use features than the Engine, we don't have to implement ourselves


Thanks


Rose


 


 



Rose, 
  
 After tracking lines on the map, the drawn lines will be saved to 
  winformsMap1.EditOverlay.EditLayer  
 which is an InMemoryFeatureLayer and you can easily get all the features through  winformsMap1.EditOverlay.EditLayer.InternalFeatures. 
  
 Thanks, 
  
 Ben

I see I started another thread with this exact question... what event gets elevated when the user double-clicks to end the line or polygon drawing?    If we know that event, we can go get the user-drawn features.



Ted, 
  
   I hope to have a dll pack for you tomorrow for this.  Note that this will be an interim build and not an official release. 
  
 David

David:


Can I get the dll pack you mentioned above?


thx


Rose


 






 


Rose,


We will send the temporary package to you today or tomorrow by email.  We will send it to the account you registered and please contact support@thinkgeo.comif you have any issues.


 


Thanks,


Ben