Recently I have been working on the B/S project. Although I feel that it is not difficult, the complicated process and huge workload are helpless. There was no time to study GIS at work, so I had to go back to work and study it. As mentioned above, this section will introduce the right-click menu of maptoccontrol. Haha, This is not sorted out yet. Let's look at the GIS Query first. Haha.
Old Rules: You can see the truth in a picture.
In GIS, queries are classified into attribute queries and spatial queries. The corresponding interfaces are iqueryfilter and ispatialfilter. Of course, the latter inherits the former.
In, click ballooncallout with the mouse to bring up the ballooncallout, which is implemented by space query. In the query condition on the right, click the query button to locate the query as a property query. (Haha, I want you to know it at first glance .)
①: Property query code:
Code
# Query region attributes
Private void btnsearchcity_click (Object sender, eventargs E)
{
Iactiveview pactiveview = axmapmain. Map as iactiveview;
Igraphicscontainer pgrahpicscontainer = pactiveview as igraphicscontainer;
// Clear first
Pgrahpicscontainer. deleteallelements ();
Axmapmain. extent = pactiveview. fullextent;
Axmapmain. activeview. screendisplay. updatewindow ();
Ifeaturelayer pfeaturelayer = axmapmain. get_layer (1) as ifeaturelayer;
If (null = pfeaturelayer) MessageBox. Show ("select a layer not a feature layer ");
Iqueryfilter queryfilter = new queryfilterclass ();
Queryfilter. whereclause = "name = '" + this. cbcity. Text + "'";
Ifeaturecursor featurecursor = pfeaturelayer. Search (queryfilter, false );
Ifeature pfeature = NULL;
While (pfeature = featurecursor. nextfeature ())! = NULL)
{
Axmapmain. flashshape (pfeature. Shape );
}
}
# Endregion
②: Space Query
Code
# Region geometric Query
Private void axmapmain_onmousedown (Object sender, imapcontrolevents2_onmousedownevent E)
{
Ifeaturelayer pfeaturelayer = axmapmain. get_layer (1) as ifeaturelayer;
If (null = pfeaturelayer) return;
Ipoint point = new pointclass ();
Point. x = E. MapX;
Point. Y = E. mapy;
Ispatialfilter spatialfilter = new spatialfilterclass ();
Spatialfilter. Geometry = point;
Spatialfilter. spatialrel = esrispatialrelenum. esrispatialrelintersects;
Ifeaturecursor featurecursor = pfeaturelayer. Search (spatialfilter, true );
Ifeature pfeature = featurecursor. nextfeature ();
While (pfeature! = NULL)
{
Int Index = pfeature. Table. findfield ("name ");
String name = pfeature. Table. getrow (pfeature. OID). get_value (INDEX). tostring ();
Addballooncallout (E. MapX, E. mapy, name );
Axmapmain. flashshape (pfeature. Shape );
Pfeature = featurecursor. nextfeature ();
}
System. Threading. thread. Sleep (1000 );
Iactiveview pactiveview = axmapmain. Map as iactiveview;
Igraphicscontainer pgrahpicscontainer = pactiveview as igraphicscontainer;
Pgrahpicscontainer. deleteallelements ();
Axmapmain. activeview. screendisplay. updatewindow ();
Pactiveview. partialrefresh (esriviewdrawphase. esriviewgraphics, null, null );
}
# Endregion