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类的更多相关文章

  1. arcgis for js学习之Draw类

    arcgis for js学习之Draw类 <!DOCTYPE html> <html> <head> <meta http-equiv="Cont ...

  2. js学习(五)-全局函数和类内部函数区别

    //---------------------------js代码--------------------------- function User(){       //类成员的定义及构造函数 th ...

  3. Arcgis for Js之加载wms服务

    概述:本节讲述Arcgis for Js加载ArcgisServer和GeoServer发布的wms服务. 1.定义resourceInfo var resourceInfo = { extent: ...

  4. Arcgis for Js之鼠标经过显示对象名的实现

    在浏览地图时,移动鼠标经过某个对象或者POI的时候,能够提示该对象的名称对用户来说是很实用的,本文讲述在Arcgis for Js中,用两种不同的方式来实现该效果. 为了有个直观的概念,先给大家看看实 ...

  5. js学习之变量、作用域和内存问题

    js学习之变量.作用域和内存问题 标签(空格分隔): javascript 变量 1.基本类型和引用类型: 基本类型值:Undefined, Null, Boolean, Number, String ...

  6. 【Knockout.js 学习体验之旅】(2)花式捆绑

    本文是[Knockout.js 学习体验之旅]系列文章的第2篇,所有demo均基于目前knockout.js的最新版本(3.4.0).小茄才识有限,文中若有不当之处,还望大家指出. 目录: [Knoc ...

  7. 【Knockout.js 学习体验之旅】(1)ko初体验

    前言 什么,你现在还在看knockout.js?这货都已经落后主流一千年了!赶紧去学Angular.React啊,再不赶紧的话,他们也要变out了哦.身旁的90后小伙伴,嘴里还塞着山东的狗不理大蒜包, ...

  8. Backbone.js学习之一

    昨天一个我崇拜的朋友,徐飞送我一本名为<Backbone.js实战>书,让我心中狂喜,于是带着这份浓厚的兴趣,开始研究Backbone.js之路. 打开这本书的第一句话就很有哲理,“授人以 ...

  9. Arcgis for JS之Cluster聚类分析的实现(基于区域范围的)

    原文:Arcgis for JS之Cluster聚类分析的实现(基于区域范围的) 咱们书接上文,在上文,实现了基于距离的空间聚类的算法实现,在本文,将继续介绍空间聚类之基于区域范围的实现方式,好了,闲 ...

随机推荐

  1. PHP workerMan tcp与webSocket 透传互通

    <?php $work_path = dirname(__FILE__); chdir($work_path); use \Workerman\Worker; use \Workerman\Li ...

  2. ThreadLocal及InheritableThreadLocal的原理剖析

    我们知道,线程的不安全问题,主要是由于多线程并发读取一个变量而引起的,那么有没有一种办法可以让一个变量是线程独有的呢,这样不就可以解决线程安全问题了么.其实JDK已经为我们提供了ThreadLocal ...

  3. [Swift]LeetCode351. 安卓解锁模式 $ Android Unlock Patterns

    Given an Android 3x3 key lock screen and two integers m and n, where 1 ≤ m ≤ n ≤ 9, count the total ...

  4. [Swift]LeetCode768. 最多能完成排序的块 II | Max Chunks To Make Sorted II

    This question is the same as "Max Chunks to Make Sorted" except the integers of the given ...

  5. mysql_study_2

    select 代码: CREATE DATABASE mysql_shiyan; use mysql_shiyan; CREATE TABLE department ( dpt_name ) NOT ...

  6. Python数据挖掘指南

    Data Mining in Python: A Guide 转载原文:https://www.springboard.com/blog/data-mining-python-tutorial/(全英 ...

  7. 12.Flask-Restful

    定义Restful的视图 安装:pip install flask-restful 如果使用Flask-restful,那么定义视图函数的时候,就要继承flask_restful.Resourse类, ...

  8. BBS论坛(十五)

    15.1.登录界面完成 (1)front/signbase.html {% from 'common/_macros.html' import static %} <!DOCTYPE html& ...

  9. 我曾做过陈士成,也做过孔乙己,还做过阿Q

    一. 我现在是陈士成,陈士成现在是我.为什么这么说呢? 那年那天,天刚微微亮,似乎还在打着哈欠.我和父亲去得很早,为的就是在“小升初的考试成绩榜单”前面占一个有利的位置.我不记得当时穿的厚还是不厚,体 ...

  10. Elasticsearch之删除索引

    1. #删除指定索引    # curl -XDELETE -u elastic:changeme http://localhost:9200/acc-apply-2018.08.09    {&qu ...