C # search for features on the mapobject2 Control

Source: Internet
Author: User

For project reasons, the customer needs a map and each layer is displayed. the last layer contains the features of all branches. He wants to query data by selecting the features. TMD, this is the first time he has done this, the core is just a few words. It is very convenient to add layers. It is really complicated to search for features. If you have no books or materials, go to ERSI for help! E. Headaches

The Code is as follows:

Lstdept. Items. Clear (); // display the ListBox of the branch name
Lstid. Items. Clear (); // ListBox of the branch ID
Mapobjects2.rectangle prect = axmapobj. trackrectangle (); // use the giant area selected by the mouse
Mapobjects2.recordset pdaord = NULL;

Mapobjects2.maplayer layer = (mapobjects2.maplayer) axmapobj. layers. Item (0); // The top layer. axmapobj is the name of the map control.
Pdaord = Layer. searchshape (prect, mapobjects2.searchmethodconstants. mocontaining, ""); // use the DaO object, mainly the searchshape Method

If (pdaord! = NULL) pdaord. movefirst ();
While (! Pdaord. EOF)
{
String sdeptname = "";
String sdeptid = "";

Sdeptname = pdaord. Fields. Item ("unitname"). valueasstring;
Sdeptid = pdaord. Fields. Item ("unitid"). valueasstring;

If (sdeptname! = String. Empty & sdeptid! = String. Empty)
{
Lstdept. Items. Add (sdeptname );
Lstid. Items. Add (sdeptid );
}
Pdaord. movenext ();
}

This code is stored in the mousedownevent event of the axmapobj map control. Now, find the branch number and use the query in your database! My homepage: itbaby.jss.cn

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.