current position:Home>18 ArcGIS API for JavaScript 4.18 obtain the length and area after drawing line segments and surface features

18 ArcGIS API for JavaScript 4.18 obtain the length and area after drawing line segments and surface features

2022-04-29 16:10:12X Beichen North

Write it at the front

In the previous article, we introduced how to draw points in the form of mouse click 、 Line 、 Surface elements , After reading the code, you should feel that it is actually very simple , Is to use "esri/widgets/Sketch/SketchViewModel" This API Module to achieve .

The general implementation process is as follows :

  • Instantiation SketchViewModel
  • Set point 、 Line 、 The styles of the three symbols of the face
  • Activate SketchViewModel Corresponding drawing tools
  • draw

The above is to draw points in the form of mouse click 、 Line 、 The overall process of face elements , We can take a look at this process by drawing a point element code below , The code is as follows :

//  Instantiate a before drawing Graphic Layers , Used to store drawn points 、 Line 、 Surface elements 
const graphicsLayer = new GraphicsLayer({
	id: 'pointGraphicLayer',
	elevationInfo: {
		mode: 'on-the-ground',
	},
});
mainView.map.add(graphicsLayer);

// 2、 Set the symbol of the point feature 
const pointSymbol = {
	type: 'simple-marker',
	style: 'diamond',
	color: '#d81e06',
	size: '32px',
	outline: {
		color: [255, 255, 255],
		width: 3,
	},
};

// 1、 Instantiation SketchViewModel example 
var sketchViewModel = new SketchViewModel({
	updateOnGraphicClick: false,
	view: mai

copyright notice
author[X Beichen North],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291427264577.html

Random recommended