Obtain the region range of the element drawn on IMAP.

Source: Internet
Author: User

Runtime Environment: Development Environment: 64bit, visualstudio2008 with SP1, arcengine10.0, netframework4.0, iis7, and C # development languages for Windows 7 flagship edition.

Problem description: In the past, the section analysis function of CS was to draw the broken parts on the IMAP, and then display the axmapcontrol. Now we need to transplant it to WebService, and naturally there is no control to display it, therefore, you can export the elements drawn in IMAP as images directly. However, during image export, the exported regions are not the regions where the elements are drawn, therefore, you must first obtain the region range of the elements you have drawn.

The following is a method to obtain the public external rectangle of the elements to be drawn. You only need to obtain the public external rectangle after the painting is complete, and then export the region as an image.

1: // obtain the overall scope of the painting Element
   2: IEnumElement pEnumElem;
   3: IGraphicsContainer graphicsContainer = pMap as IGraphicsContainer;
   4: IGraphicsContainerSelect pGraphicsContainerSelect = pMap as IGraphicsContainerSelect;
   5: pGraphicsContainerSelect.SelectAllElements();
   6: pEnumElem = pGraphicsContainerSelect.SelectedElements;
   7: IElement ele = pEnumElem.Next();
   8: IEnvelope env = new EnvelopeClass();
   9: while (ele != null)
  10: {
  11:     IGeometry geo = ele.Geometry;
  12:     ele = pEnumElem.Next();
  13:     env.Union(geo.Envelope);
  14: }
  15: pActiveView.Extent = env;
  16: pGraphicsContainerSelect.UnselectAllElements();

The last obtained env is the required public external rectangle.

Note: In this process, the envelop of text elements is processed as vertices. Therefore, if a text element exists on the periphery, you need to adjust the position based on the actual situation. Alternatively, you can obtain the external rectangle of the text for calculation, which is more accurate.

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.