arcgis for js学习之Graphic类
arcgis for js学习之Graphic类
<title>Graphic类</title>
<meta charset="utf-8" />
<!-- 说明:Graphic类
一个graphic类包括四个基本的参数:一个geometer,一个symbol,attribute和infoTemplate.
Grpaphic只能显示在GraphicsLayer对象中,即在GraphicLayer上监听Graphic对象。
两种实例化的方式:
new Graphic(geometry,symbol,attributes,infoTemplate)
new Grpahic(json)
-->
<!-- data 属性:
data-class-break:
data-geometry-type:几何类型:point,polyline,polygon ,multipoint
data-hidden:添加到图形中的节点时隐藏
data-selected:添加到图形中的节点被选中
-->
<!-- 属性:
attributes:属性字段值
geometry:定义一个几何图形
infoTemplate:infoWindow中显示的内容
symbol:图形的样式
visible:图形的可见性
-->
<!-- 方法:
attr(name,value):修改属性值
draw():绘制图形
getContent():返回内容的值
getDojoShape():
getInfoTemplate():返回信息模板
getLayer():返回一个图层的
getNode():返回节点用于绘制图层
getNodes():返回多个节点
getShape():返回一个esri图形
getShapes():。。。。
getATitle():获取标题
hide():隐藏图形
setAttributes(attributes):定义图形的属性
setGeometry(geometry):定义几何图形
setInfoTemplate(infoTempate):定义一个infoWindow
setSymbol(symbol):设置图形的象征
show():显示图形
toJson():将对象转换为json标的是的gis服务器
-->
<script>
//实例一:最基本的图形
require([
"esri/geometry/Point", "esri/symbols/SimpleMarkerSymbol",
"esri/Color", "esri/InfoTemplate", "esri/graphic"
], function (Point, SimpleMarkerSymbol, Color, InfoTemplate, Graphic) {
var pt = new Point(xloc, yloc, map.spatialReference);
var sms = new SimpleMarkerSymbol().setStyle(SimpleMarkerSymbol.STYLE_SQUARE).setColor(new Color([225, 0, 0, 0.5]));
var attr = {
"Xcoord": evt.mapPoint.x,
"Ycoord": evt.mapPoint.y,
"Plant": "Mesa Mint"
};
var infoTemplate = new InfoTemplate("");
var graphic = new Graphic(pt, sms, attr, infoTemplate);
});
//实例二:创建一个线图形
require([
"esri/graphic"
], function (Graphic) {
var myLine = {
geometry: {
"path": [[[111, 222], [222, 333]]],
"spatialReference": { "wkid": 4326 }
},
"symbol": {
"color": [0, 0, 0, 255],
"width": 1,
"type": "esriSLS",
"style": "esriSLSSolid"
}
};
var gra = new Graphic(myLine);
});
//实例三:创建一个面图层
require([
"esri/graphic"
], function (Graphic) {
var myPolygon = {
"geometry": {
"rings": [[[222, 333], [333, 222], [334, 666]]],
"spatialReference": { "wkid": 4326 }
},
"symbol": {
"color": [0, 0, 0, 64],
"outline": {
"outline": [0, 0, 0, 255],
"width": 1,
"type": "esriSLS",
"style": "esriSFSSolid"
}
}
};
var gra = new Graphic(myPolygon);
});
//实例四:创建多个点
require([
"esri/graphic"
], function (Graphic) {
var myPoint = {
"geometry": {
"x": 333,
"y": 222,
"spatialReference": { "wkid": 4326 }
},
"attributes": {
"Xcoord": 222.222,
"Ycoord": 333.333,
"Plant": "Mesa Mint"
},
"symbol": {
"color": [222, 0, 0, 222],
"size": 12,
"angle": 0,
"xoffest": 0,
"yoffest": 0,
"type": "esriSMS",
"style": "esriSMSSquare",
"outline": {
"color": [0, 0, 0, 233],
"width": 1,
"type": "esriSLS",
"type": "esriSLSSOlid"
}
},
"infoTemplate": {
"title": "sssss",
"content": "latude:${Field}"
}
};
var gra = new Graphic(myPoint);
})
</script>
arcgis for js学习之Graphic类的更多相关文章
- arcgis for js学习之Draw类
arcgis for js学习之Draw类 <!DOCTYPE html> <html> <head> <meta http-equiv="Cont ...
- js学习(五)-全局函数和类内部函数区别
//---------------------------js代码--------------------------- function User(){ //类成员的定义及构造函数 th ...
- Arcgis for Js之加载wms服务
概述:本节讲述Arcgis for Js加载ArcgisServer和GeoServer发布的wms服务. 1.定义resourceInfo var resourceInfo = { extent: ...
- Arcgis for Js之鼠标经过显示对象名的实现
在浏览地图时,移动鼠标经过某个对象或者POI的时候,能够提示该对象的名称对用户来说是很实用的,本文讲述在Arcgis for Js中,用两种不同的方式来实现该效果. 为了有个直观的概念,先给大家看看实 ...
- js学习之变量、作用域和内存问题
js学习之变量.作用域和内存问题 标签(空格分隔): javascript 变量 1.基本类型和引用类型: 基本类型值:Undefined, Null, Boolean, Number, String ...
- 【Knockout.js 学习体验之旅】(2)花式捆绑
本文是[Knockout.js 学习体验之旅]系列文章的第2篇,所有demo均基于目前knockout.js的最新版本(3.4.0).小茄才识有限,文中若有不当之处,还望大家指出. 目录: [Knoc ...
- 【Knockout.js 学习体验之旅】(1)ko初体验
前言 什么,你现在还在看knockout.js?这货都已经落后主流一千年了!赶紧去学Angular.React啊,再不赶紧的话,他们也要变out了哦.身旁的90后小伙伴,嘴里还塞着山东的狗不理大蒜包, ...
- Backbone.js学习之一
昨天一个我崇拜的朋友,徐飞送我一本名为<Backbone.js实战>书,让我心中狂喜,于是带着这份浓厚的兴趣,开始研究Backbone.js之路. 打开这本书的第一句话就很有哲理,“授人以 ...
- Arcgis for JS之Cluster聚类分析的实现(基于区域范围的)
原文:Arcgis for JS之Cluster聚类分析的实现(基于区域范围的) 咱们书接上文,在上文,实现了基于距离的空间聚类的算法实现,在本文,将继续介绍空间聚类之基于区域范围的实现方式,好了,闲 ...
随机推荐
- [Swift]LeetCode461. 汉明距离 | Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits ...
- [Swift]LeetCode710. 黑名单中的随机数 | Random Pick with Blacklist
Given a blacklist B containing unique integers from [0, N), write a function to return a uniform ran ...
- [Swift]LeetCode721. 账户合并 | Accounts Merge
Given a list accounts, each element accounts[i] is a list of strings, where the first element accoun ...
- [Swift]LeetCode955. 删列造序 II | Delete Columns to Make Sorted II
We are given an array A of N lowercase letter strings, all of the same length. Now, we may choose an ...
- python glob的安装和使用
基本概念 glob是python自己带的一个文件操作相关模块,用它可以查找符合自己目的的文件,类似于Windows下的文件搜索,支持通配符操作.*,?,[]这三个通配符,*代表0个或多个字符,?代表一 ...
- CMake根据平台移植检查设置文件编译选项
#添加函数检查功能 include(CheckFunctionExists) //检查系统是否支持accpet4,将检查结果设置至HAVE_ACCEPT4 check_function_exists( ...
- 别再说Python没有枚举类型了,好好看看
枚举类型可以看作是一种标签或是一系列常量的集合,通常用于表示某些特定的有限集合,例如星期.月份.状态等. Python 的原生类型(Built-in types)里并没有专门的枚举类型,但是我们可以通 ...
- wget Mac OS 下安装
wget是一个从网络上自动下载文件的自由工具,支持通过HTTP.HTTPS.FTP三个最常见的TCP/IP协议下载,并可以使用HTTP代理. 下面介绍如何在Mac OS 下安装Wget 下载最新版的 ...
- 『字符串模式匹配 KMP』
字符串模式匹配 我们要先了解一下问题是什么. 模式匹配是数据结构中字符串的一种基本运算,给定一个子串,要求在某个字符串中找出与该子串相同的所有子串,这就是模式匹配. KMP 然后我们来认识一下今天的主 ...
- Kafka分区与消费者的关系
1. 前言 我们知道,生产者发送消息到主题,消费者订阅主题(以消费者组的名义订阅),而主题下是分区,消息是存储在分区中的,所以事实上生产者发送消息到分区,消费者则从分区读取消息,那么,这里问题来了, ...