Mapxtreme GEO chart

Source: Internet
Author: User

Using system;
Using system. collections;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. Web;
Using system. Web. sessionstate;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. htmlcontrols;
Using MapInfo;
Using MapInfo. Data. Find;
Using MapInfo. Data;
Using MapInfo. geometry;
Using MapInfo. styles;
Using MapInfo. Mapping. thematics;
Using MapInfo. Mapping;
Using MapInfo. Mapping. Legends;
Using MapInfo. webcontrols;
Using applicationstatemanager;

Namespace

// Bind the country name to the menu

Private Static string _ findlayername = "worldcap ";
Private Static string _ findcolumnname = "country ";

Protected override void onprerender (eventargs E)
{
If (! Ispostback)
{
Filldropdown (_ findlayername, _ findcolumnname );
}
}

 

Private void filldropdown (string tablename, string colname)
{
MapInfo. Mapping. Map map = NULL;

// Get the map
If (MapInfo. Engine. session. Current. mapfactory. Count = 0 |
(MAP = MapInfo. Engine. session. Current. mapfactory [mapcontrol1.mapalias]) = NULL)
{
Return;
}

Ddlcity. Items. Clear ();

MapInfo. mapping. featurelayer FL = (MapInfo. mapping. featurelayer) map. layers [tablename];
MapInfo. data. table T = FL. table;
midatareader TR;
miconnection con = new miconnection ();
micommand Tc = con. createcommand ();
TC. commandtext = "select" + colname + "from" + T. alias;
// convert. todatetime ("AFDS");
con. open ();
TR = tc. executereader ();
while (TR. read ()
{< br> ddlcity. items. add (TR. getstring (0);

}
TC. Cancel ();
TC. Dispose ();
Tr. Close ();
Con. Close ();

}

// Search for a country on the map
Private Static string _ workinglayername = "workinglayer ";
Protected void butfind_click (Object sender, eventargs E)
{
Find find = NULL;
Try
{
MapInfo. Mapping. Map map = NULL;

// get the map
If (MapInfo. engine. session. current. mapfactory. count = 0 |
(MAP = MapInfo. engine. session. current. mapfactory [mapcontrol1.mapalias]) = NULL)
{< br> return;
}

// do the find
MapInfo. mapping. featurelayer findlayer = (MapInfo. mapping. featurelayer) map. layers [_ findlayername];
Find = new find (findlayer. table, findlayer. table. tableinfo. columns [_ findcolumnname]);
findresult result = find. search (ddlcity. selecteditem. text);

If (result. exactmatch)
{< br> // create a feature (point) for the location we found
coordsys csys = findlayer. coordsys;
featuregeometry G = new MapInfo. geometry. point (csys, result. foundpoint. x, result. foundpoint. y);
feature F = new feature (G, new MapInfo. styles. simplevectorpointstyle (52, system. drawing. color. darkgreen, 32);

// Delete the existing find object and add the new one
MapInfo. mapping. featurelayer workinglayer = (MapInfo. mapping. featurelayer) map. layers [_ workinglayername];
If (workinglayer! = NULL)
{< br> (workinglayer. table as itablefeaturecollection ). clear ();
workinglayer. table. insertfeature (f);
}

// Set the map's center and zooom
Map. Center = new dpoint (result. foundpoint. X, result. foundpoint. y );
MapInfo. Geometry. distance d = new MapInfo. Geometry. Distance (1, map. Zoom. Unit );
Map. Zoom = D;
}
Else
{
Response. Write ("nothing ");
}
Find. Dispose ();
}
Catch (exception)
{
If (find! = NULL) find. Dispose ();
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.