MapXtreme 2005 to create a learning experience points / lines on a map and display the mark (five)

New examples

 

1: New Project

Create a new Web site, select MapXtreme 6.7.1 Web Application

in App_Code, we create a new class named: LayerManager.cs

 

2: Section put into function in the class LayerManager

The function code on a full copy over, as well as using namespace

 

3: Open MapForm.cs, in the Page_Load code, add the following code

05233313_vhQE.gif 05233313_w2ZV.gif Code String  tableName  = " tableName " , layerName  = " layerName " ; // just define two names         LayerManager.CreateLayer (tableName, layerName); // create layers         LayerManager.AddPoint (layerName, GetDPoint ( 60 , 60 ),  35 , Color.Red); // Create a pentagram red dot         LayerManager.AddLine (layerName, GetDPoint ( 160. 160. ), GetDPoint ( 300 160. ),  59 , Color.Red); // Create a single red line arrow
   



        LayerManager.ShowValue (tableName,  " value " ); // display labels

Description:

There is a GetDPoint (int x, int y) function, mainly incoming client coordinates, latitude and longitude Back to map

 

GetDPoint follows function

05233313_vhQE.gif 05233313_w2ZV.gif Code
Private  DPoint GetDPoint ( int  X, int  Y)
05233313_w2ZV.gif05233313_vhQE.gif    
{         DPoint DP  = new new  DPoint ();         the System.Drawing.Point Point  = new new  the System.Drawing.Point (X, Y); // client coordinates (relative map)         the Map Map  =  MapInfo.Engine.Session.Current.MapFactory [ 0 ];         map.DisplayTransform.FromDisplay (Point,  OUT  DP); // switch to the corresponding latitude and longitude coordinates return  DP;     }
 
 


        

4: full page code is as follows

05233313_vhQE.gif 05233313_w2ZV.gif Code
public partial class _Default : System.Web.UI.Page 
05233313_w2ZV.gif05233313_vhQE.gif
{
    
private void Page_Load(object sender, System.EventArgs e)
05233313_ycme.gif05233313_ROlt.gif    
{
        
// If the StateManager doesn't exist in the session put it else get it.
        if (StateManager.GetStateManagerFromSession() == null)
            StateManager.PutStateManagerInSession(
new AppStateManager());

        
// Now Restore State
        StateManager.GetStateManagerFromSession().ParamsDictionary[StateManager.ActiveMapAliasKey] = MapControl1.MapAlias;
        StateManager.GetStateManagerFromSession () RestoreState ();.

        
String  tableName  = " tableName " , layerName  = " layerName " ; // just define two names         LayerManager.CreateLayer (tableName, layerName); // create layers         LayerManager.AddPoint (layerName, GetDPoint ( 60 , 60 ),  35 , Color.Red); // Create a pentagram red dot         LayerManager.AddLine (layerName, GetDPoint ( 160. 160. ), GetDPoint ( 300 160. ),  59  


, Color.Red); // Create a single red line arrow         LayerManager.ShowValue (tableName,  " value " ); // show marked     }

Private  DPoint GetDPoint ( int  X, int  Y) {         DPoint DP  = new new  DPoint ();         Point the System.Drawing.Point  = new new  the System.Drawing.Point (X, Y); // client coordinates (relative map)         the map map  =  MapInfo.Engine.Session.Current.MapFactory [ 0 ];         map.DisplayTransform.FromDisplay ( Point,  OUT  dp); //
    

05233313_ycme.gif05233313_ROlt.gif    

 
 

转成相应的经纬度坐标
        return dp;
    }

    
// At the time of unloading the page, save the state
    private void Page_UnLoad(object sender, System.EventArgs e)
05233313_ycme.gif05233313_ROlt.gif    
{
        StateManager.GetStateManagerFromSession().SaveState();
    }

}

5: operating results

OK, save, view, you can see on the page in the appropriate place, we created a five-pointed star and a red arrow-way line

 

 

Reproduced in: https: //my.oschina.net/secyaher/blog/274116

Guess you like

Origin blog.csdn.net/weixin_33806300/article/details/91966797
Recommended