ArcGIS js api 手动构建FeatureLayer
坐标系
var spatialReference = new SpatialReference(4326);
1
要素坐标点
var pointArr = [
new Point(116.94431351934418, 36.642791191513744, spatialReference),
new Point(116.94313181636085,36.644263733181496, spatialReference),
new Point(116.94323946773243, 36.644333923319806, spatialReference),
new Point(116.94214699103674, 36.64316768441554, spatialReference),
new Point(116.94173145496477, 36.643359669286696, spatialReference),
new Point(116.94251530866333, 36.644235392555245, spatialReference),
];
构建features
var features = [];
for (var i = 0; i < pointArr.length; i++) {
var graphics = new Graphic(pointArr[i], pointSymbol, { "OBJECTID": i, "LON": pointArr[i].x, "LAT": pointArr[i].y });
features.push(graphics);
}
构建fields
var fields = [
{ name: "OBJECTID", type: "esriFieldTypeOID", alias: "OBJECTID" },
{ name: "LON", type: "esriFieldTypeDouble", alias: "LON" },
{ name: "LAT", type: "esriFieldTypeDouble", alias: "LAT" }
];
构建featuresSet
var featureSetJson = {
displayFieldName: "",
geometryType: "esriGeometryPoint",
fieldAliases: {
OBJECTID: "OBJECTID",
LON: "LON",
LAT: "LAT"
},
fields: fields,
spatialReference: spatialReference,
features: features
};
var featuresSet = new FeatureSet(featureSetJson);
构建featureCollection
var layerDefinition = {
"geometryType": "esriGeometryPoint",
"fields": fields
};
var featureCollection = {
layerDefinition: layerDefinition,
featureSet: featuresSet
};
构建FeatureLayer
var featureLayer = new FeatureLayer(featureCollection);
1
完整代码
require([
"esri/map",
"esri/SpatialReference",
"esri/layers/FeatureLayer",
"esri/geometry/Point",
"esri/tasks/FeatureSet",
"esri/graphic",
"dojo/domReady!"
],
function (Map, SpatialReference, FeatureLayer, Point, FeatureSet, Graphic) {
var map = new Map("viewDiv", {
basemap: "streets",
center: [116.943089, 36.643737],
zoom: 18
});
var spatialReference = new SpatialReference(4326);
var pointArr = [
new Point(116.94431351934418, 36.642791191513744, spatialReference),
new Point(116.94313181636085,36.644263733181496, spatialReference),
new Point(116.94323946773243, 36.644333923319806, spatialReference),
new Point(116.94214699103674, 36.64316768441554, spatialReference),
new Point(116.94173145496477, 36.643359669286696, spatialReference),
new Point(116.94251530866333, 36.644235392555245, spatialReference),
];
var features = [];
for (var i = 0; i < pointArr.length; i++) {
var graphics = new Graphic(pointArr[i], pointSymbol, { "OBJECTID": i, "LON": pointArr[i].x, "LAT": pointArr[i].y });
features.push(graphics);
}
var fields = [
{ name: "OBJECTID", type: "esriFieldTypeOID", alias: "OBJECTID" },
{ name: "LON", type: "esriFieldTypeDouble", alias: "LON" },
{ name: "LAT", type: "esriFieldTypeDouble", alias: "LAT" }
];
var featureSetJson = {
displayFieldName: "",
geometryType: "esriGeometryPoint",
fieldAliases: {
OBJECTID: "OBJECTID",
LON: "LON",
LAT: "LAT"
},
fields: fields,
spatialReference: spatialReference,
features: features
};
var featuresSet = new FeatureSet(featureSetJson);
var layerDefinition = {
"geometryType": "esriGeometryPoint",
"fields": fields
};
var featureCollection = {
layerDefinition: layerDefinition,
featureSet: featuresSet
};
var featureLayer = new FeatureLayer(featureCollection);
map.addLayer(featureLayer);
})
api参考
https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html#featurelayer2
https://developers.arcgis.com/javascript/3/jsapi/featureset-amd.html#featureset2
有疑问可加1936057493
---------------------
作者:cjchnvs
来源:CSDN
原文:https://blog.csdn.net/qq_22267353/article/details/81233263
版权声明:本文为博主原创文章,转载请附上博文链接!
ArcGIS js api 手动构建FeatureLayer的更多相关文章
- geoserver图层属性查询及查询结果转换为arcgis js api能使用的格式
一个项目使用了ArcGIS JS API开发GIS展示层,但GIS服务使用了Geoserver,这时加载Geoserver数据和查询数据就和之前完全不一样了,以下介绍下我使用ArcGIS JS API ...
- 基于ArcGIS JS API的在线专题地图实现
0 引言 专题地图是突出而深入的表示一种或几种要素或现象,即按照地图主题的要求,集中表示与主题有关内容的地图.专题地图的专题要素多种多样,分类方法也多种多样,根据专题地图表现数据的特点可分为定 ...
- 关于ueditor与arcgis js api同用会报错的问题
在ueditor与arcgis js api共用时,需要将ueditor\third-party\zeroclipboard\ZeroClipboard.js中的 if (typeof define ...
- ArcGIS JS API使用PrintTask打印地图问题解决汇总
环境:来源于工作过程,使用的API是 arcgis js 3.* 3系API,4.*暂时没测试: 1.数据与打印服务跨域情况下,不能打印问题. 一般情况下,我们发布的数据服务和打印服务是在一台服务 ...
- arcgis js api 本地化配置
配置arcgis library 根目录的init.js的 "baseUrl:",使其指向正确的地址
- Arcgis js API使用wmts方式加载GeoWebCache中的切片地图(转载)
使用GeoWebCache的主要目的是其独立安装版能够发布arcgis的切片.我们知道,使用openlayer是调用geoserver最方便的方法,那么在发布完arcgis的切片后,怎么用arcgis ...
- arcgis js api 4.X 自定义工具按钮
// All material copyright ESRI, All Rights Reserved, unless otherwise specified. // See https://js.a ...
- ArcGIS JS Api 4.x修改三维球背景技巧
通过修改scenceview.js中tileBackground和defaultTileBackground中的png的base64编码就可以达到要求. 4.8中通过修改scenceview. ...
- ArcGIS JS API多线程克里金插值
最近做关于雨量插值的项目,本来使用后台的GP工具做的,但是处理时间比较长需要十几秒钟左右,所以研究怎么通过前台来计算. 参考下克里金例子,思路是生成要计算区域的100乘以100网格,然 ...
随机推荐
- android 日期控件 DatePicker
DatePicker的缺陷 提供的API太少,没办法个性化定制.比如,不能指定某部分的颜色,不能控制显示的部分等. xml中提供的属性太少,同样影响定制化. 兼容性问题太多,在4.x,5.x和6.0+ ...
- [日常] Go语言圣经--结构体,JSON习题
Go语言圣经-结构体 1.结构体是一种聚合的数据类型,是由零个或多个任意类型的值聚合成的实体 2.通常一行对应一个结构体成员,成员的名字在前类型在后,不过如果相邻的成员类型如果相同的话可以被合并到一行 ...
- 【JavaFx教程】第六部分:统计图
第6部分的主题 创建一个统计图显示生日的分布. 生日统计 在AddressApp中所有人员都有生日.当我们人员庆祝他们生日的时候,如果有一些生日的统计不是会更好. 我们使用柱状图,包含每个月的一个条形 ...
- Android-加载图片避免OOM
http://blog.csdn.net/guolin_blog/article/details/9316683 高效加载大图片 我们在编写Android程序的时候经常要用到许多图片,不同图片总是会有 ...
- Java - HashMap 多线程安全解析
HashMap多线程并发问题分析 多线程put后可能导致get死循环 从前我们的Java代码因为一些原因使用了HashMap这个东西,但是当时的程序是单线程的,一切都没有问题.后来,我们的程序性能有问 ...
- Code Signal_练习题_evenDigitsOnly
Check if all digits of the given integer are even. Example For n = 248622, the output should beevenD ...
- django使用小贴士
问题一: RuntimeError: Model class user.models.UserAccount doesn't declare an explicit app_label 解决方案 方案 ...
- python-命令模式
源码地址:https://github.com/weilanhanf/PythonDesignPatterns 说明: 命令在发送方被激活,而在接收方被响应.一个对象既可以作为命令的发送方,也可以作为 ...
- [World Final 2016] Branch Assignment
链接 PDF bzoj 先求出正置边和反置边时b+1到前b个点的最短路dis[0/1][x](x∈[1,b]), 令D[x]=dis[0][x]+dis[1][x] 然后分组后每个x对代价的贡献为D[ ...
- SD从零开始21-24
[原创]SD从零开始21 输出(Output) 销售的输出类型Output types in SD Output是用于和商业伙伴及系统交换信息的通信方式:你可以为不同的销售凭证如报价单,订单,交货单, ...