Home > Web Front-end > JS Tutorial > body text

How to use Arcgis to draw lines and areas and calculate their size?

青灯夜游
Release: 2018-11-10 16:06:26
forward
8172 people have browsed it

The content of this article is to introduce how to use Arcgis to draw lines and surfaces and calculate their sizes? It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

In the process of map development using Arcgis API for JavaScript, drawing lines and pictures on the map is a frequently used function. This article mainly introduces this function.

This article is applicable to Arcgis API version: Arcgis API for JS 4.x or above.

Solution analysis:

1. First, map and mapView (2D map) must be initialized;

2 , and then use Draw to draw lines and perform screen operations;

3. Finally, add the lines and surfaces to Graphic to complete the operation.

Steps

#1. First, set the container for map in html.

  How to use Arcgis to draw lines and areas and calculate their size?

2. Initialize map and mapView;

  

3 , you need to use a class when drawing lines or pictures: Draw;

  

4. In the process of drawing the picture, you need to specify the coordinate reference to be used. Department: spatialReference;

Start screen geometryEngine, calculate the size of the surface:

## html part:

JS part:

## Line drawing effect display:

Because the logic of line drawing and picture is the same Yes, it’s just that some values ​​are different, so I won’t go into more detail.

Let me say a few more words. Although I have been talking about drawing lines and pictures, in fact draw.create(drawAction,drawOption?); can also draw other shapes;

All those in the red box can be drawn You can draw points/multipoints/lines/surfaces/rectangles/circles/ellipses, and there are quite a lot of styles.

<br>drawOption is an optional parameter and does not need to be written. Judging from the official website, drawOption currently only has one attribute mode, and mode has three values: hybrid, freehand, and click.

hybridYou can click or drag dynamically to generate the specified graphics. Currently supported graphics are polyline and polygon. ##freehandclickSummary: The above is the entire content of this article, I hope it will be helpful to everyone's study.
<br>
Specifies that only dragging actions can generate graphics (imagine Hold down the left mouse button and don't let go before dragging.). Currently supported graphics are polyline and polygon.
Click to generate the specified graphic. Works with all currently supported graphics.

The above is the detailed content of How to use Arcgis to draw lines and areas and calculate their size?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!