[英]How to get graphics points after draw using arcgis api
I want to get Polygon Points, lines points in order to store them in a database. 我想获取多边形点,线点以便将其存储在数据库中。 I am using arcgis api 3.26 and i am wondering how can i get the points.
我正在使用arcgis api 3.26,我想知道如何获得积分。 here is how i draw graphics
这是我绘制图形的方式
// markerSymbol is used for point and multipoint, see http://raphaeljs.com/icons/#talkq for more examples
var markerSymbol = new SimpleMarkerSymbol();
markerSymbol.setPath("M16,4.938c-7.732,0-14,4.701-14,10.5c0,1.981,0.741,3.833,2.016,5.414L2,25.272l5.613-1.44c2.339,1.316,5.237,2.106,8.387,2.106c7.732,0,14-4.701,14-10.5S23.732,4.938,16,4.938zM16.868,21.375h-1.969v-1.889h1.969V21.375zM16.772,18.094h-1.777l-0.176-8.083h2.113L16.772,18.094z");
markerSymbol.setColor(new Color("#00FFFF"));
// lineSymbol used for freehand polyline, polyline and line.
var lineSymbol = new CartographicLineSymbol(
CartographicLineSymbol.STYLE_SOLID,
new Color([255,0,0]), 10,
CartographicLineSymbol.CAP_ROUND,
CartographicLineSymbol.JOIN_MITER, 5
);
// fill symbol used for extent, polygon and freehand polygon, use a picture fill symbol
// the images folder contains additional fill images
var fillSymbol = new PictureFillSymbol(
new SimpleLineSymbol(
SimpleLineSymbol.STYLE_SOLID,
new Color('#000'),
1
),
42,
42
);
I can display graphic using this function addGraphics 我可以使用此功能显示图形addGraphics
// figure out which symbol to use
var symbol;
if ( evt.geometry.type === "point" || evt.geometry.type === "multipoint") {
symbol = markerSymbol;
//alert(markerSymbol.xoffset);
} else if ( evt.geometry.type === "line" || evt.geometry.type === "polyline") {
symbol = lineSymbol;
//alert(lineSymbol.toJson());
}
else {
symbol = fillSymbol;
alert(fillSymbol);
}
map.graphics.add(new Graphic(evt.geometry, symbol));
alert("X: " + evt.mapPoint.x.toString() + ", <br>Y: " + evt.mapPoint.y.toString());
}
You can get the points from evt.geometry
properties : 您可以从
evt.geometry
属性获取要点:
For point: evt.geometry.x
and evt.geometry.y
对于点:
evt.geometry.x
和evt.geometry.y
For multipoint : evt.geometry.points
returns an array points https://developers.arcgis.com/javascript/3/jsapi/multipoint-amd.html#points 对于多点:
evt.geometry.points
返回一个数组点https://developers.arcgis.com/javascript/3/jsapi/multipoint-amd.html#points
For polyline : evt.geometry.path
returns an array of paths, which contain an array of points https://developers.arcgis.com/javascript/3/jsapi/polyline-amd.html#paths 对于折线:
evt.geometry.path
返回路径数组,其中包含点数组https://developers.arcgis.com/javascript/3/jsapi/polyline-amd.html#paths
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.