arcGis for javaScript4.x 简单实用的绘制点、线、面的geometry函数和symbol函数方法

1,使用new对象的默认的方法

const pointGeometry = new Point({
	longitude:-118.29026, 
	latitude:34.1816
});

const pointSymbol = new SimpleMarkerSymbol({
	color: [226, 119, 40],
	outline: {
		color: [255, 255, 255],
		width: 1
	}
})

线

const lineGeometry = new Polyline({
	paths: [
		[-118.29026, 34.1816],
		[-118.26451, 34.09664]
	]
});

const lineSymbol = new SimpleLineSymbol({
	color: [226, 119, 40],
	width: 2
});

var polygonGeometry = new Polygon({
	rings: [
		[-118.27653, 34.15121],
		[-118.2446, 34.15462],
		[-118.22915, 34.14439],
		[-118.23327, 34.12279],
		[-118.25318, 34.10972],
		[-118.26486, 34.11625],
		[-118.27653, 34.15121]
	]
});

var fillSymbol = new SimpleFillSymbol({
	color: [227, 139, 79, 0.8],
	outline: {
		color: [255, 255, 255],
		width: 1
	}
});

2,使用其它的方式

export default {
    methods: {
        createPointGeometry(longitude, latitude) {
            // 创建点 Geometry new Point()
            return {
                type: 'point',
                longitude,
                latitude
            }
        },
        createPointSymbol(color, style = 'circle', size, outlineColor, outlineWidth) {
            // 绘制点 Symbol
            return {
                type: "simple-marker",
                style,  // "circle"|"square"|"cross"|"x"|"diamond"|"triangle"|"path"
                color,
                size,
                outline: {
                    color: outlineColor,
                    width: outlineWidth
                }
            };
        },
        createPictureMarkerSymbol(url, width, height) {
            // 绘制点图标 Symbol
            return {
                type: "picture-marker",
                url, width, height
            };
        },
        createPolylineGeometry(paths) {
            // 创建线 Geometry new Polyline()
            return {
                type: 'polyline',
                paths
            }
        },
        createSimpleLineSymbol(color, width = 2, style = 'solid') {
            // 创建线 simpleLineSymbol
            return {
                type: 'simple-line', 
                color, width, 
                style // "dash"|"dash-dot"|"dot"|"long-dash"|"long-dash-dot"|
                	 // "long-dash-dot-dot"|"none"|"short-dash"|"short-dash-dot"
                	 // |"short-dash-dot-dot"|"short-dot"|"solid"
            }
        },
        createFillGeometry(rings = []) {
            // 创建图形 polygon new Polygon()
            return {
                type: 'polygon',
                rings
            }
        },
        createFillSymbol(color, style = 'solid', width, outlineColor) {
            // 绘制图形Symbol
            return {
                type: "simple-fill",    
                style,		// "backward-diagonal"|"cross"|"diagonal-cross"
                			//|"forward-diagonal"|"horizontal"|"none"|"solid"|"vertical"
                color,
                outline: {
                    color: outlineColor,
                    width
                }
            };
        },
        createToScreenGeometry(x, y) {
            // 创建 mapView.toScreen(geometry) 中的点geometry,用于屏幕定位
            return {
                x, y,
                spatialReference: {
                    wkid: 4326
                }
            }
        }
    }
}

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mf_717714

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值