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. 深入分析volatile的实现原理

    synchronized是一个重量级的锁,虽然JVM对它做了很多优化,而下面介绍的volatile则是轻量级的synchronized.如果一个变量使用volatile,则它比使用synchroniz ...

  2. Java线程池核心原理剖析

    在系统开发时,我们经常会遇到“池”的概念.使用池一种以空间换时间的做法,通常在内存中事先保存一系列整装待命的对象,以供后期供其他对象随时调用.常见的池有:数据库连接池,socket连接池,线程池等.今 ...

  3. [Swift]LeetCode100. 相同的树 | Same Tree

    Given two binary trees, write a function to check if they are the same or not. Two binary trees are ...

  4. [Swift]LeetCode130. 被围绕的区域 | Surrounded Regions

    Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. A reg ...

  5. [Swift]LeetCode298. 二叉树最长连续序列 $ Binary Tree Longest Consecutive Sequence

    Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...

  6. [Swift]LeetCode824. 山羊拉丁文 | Goat Latin

    A sentence S is given, composed of words separated by spaces. Each word consists of lowercase and up ...

  7. setData方法修改data中对象或数组的属性值(小程序开发)

    今日在开发小程序地图的过程中,遇到一个问题,困扰了我一会 业务如下: 困扰点: 我不知道如何修改data中数组包含的对象是如何修改的:期初的想法还是想共享上面的数据,想的太简单了 正确的解决步骤: 直 ...

  8. [原创]利用Browser协议探测内网主机操作系统版本(无需端口无视防火墙)

    利用Browser协议可获取机器IP.MAC.机器名.操作系统.域,如图 浏览 在SMB协议中,计算机为了访问网络资源,就需要了解网络上存在的资源列表(例如在Windows下使用网络邻居查看可以访问的 ...

  9. 有点深度的聊聊JDK动态代理

    在接触SpringAOP的时候,大家一定会被这神奇的功能所折服,想知道其中的奥秘,底层到底是如何实现的.于是,大家会通过搜索引擎,知道了一个陌生的名词:动态代理,慢慢的又知道了动态代理有多种实现方式, ...

  10. 8分钟学会使用AutoMapper

    一.什么是AutoMapper与为什么用它. 它是一种对象与对象之间的映射器,让AutoMapper有意思的就是在于它提供了一些将类型A映射到类型B这种无聊的实例,只要B遵循AutoMapper已经建 ...