坐标系

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

  1. geoserver图层属性查询及查询结果转换为arcgis js api能使用的格式

    一个项目使用了ArcGIS JS API开发GIS展示层,但GIS服务使用了Geoserver,这时加载Geoserver数据和查询数据就和之前完全不一样了,以下介绍下我使用ArcGIS JS API ...

  2. 基于ArcGIS JS API的在线专题地图实现

    0 引言     专题地图是突出而深入的表示一种或几种要素或现象,即按照地图主题的要求,集中表示与主题有关内容的地图.专题地图的专题要素多种多样,分类方法也多种多样,根据专题地图表现数据的特点可分为定 ...

  3. 关于ueditor与arcgis js api同用会报错的问题

    在ueditor与arcgis js api共用时,需要将ueditor\third-party\zeroclipboard\ZeroClipboard.js中的 if (typeof define ...

  4. ArcGIS JS API使用PrintTask打印地图问题解决汇总

    环境:来源于工作过程,使用的API是  arcgis js 3.*  3系API,4.*暂时没测试: 1.数据与打印服务跨域情况下,不能打印问题. 一般情况下,我们发布的数据服务和打印服务是在一台服务 ...

  5. arcgis js api 本地化配置

    配置arcgis library 根目录的init.js的 "baseUrl:",使其指向正确的地址

  6. Arcgis js API使用wmts方式加载GeoWebCache中的切片地图(转载)

    使用GeoWebCache的主要目的是其独立安装版能够发布arcgis的切片.我们知道,使用openlayer是调用geoserver最方便的方法,那么在发布完arcgis的切片后,怎么用arcgis ...

  7. arcgis js api 4.X 自定义工具按钮

    // All material copyright ESRI, All Rights Reserved, unless otherwise specified. // See https://js.a ...

  8. ArcGIS JS Api 4.x修改三维球背景技巧

        通过修改scenceview.js中tileBackground和defaultTileBackground中的png的base64编码就可以达到要求. 4.8中通过修改scenceview. ...

  9. ArcGIS JS API多线程克里金插值

        最近做关于雨量插值的项目,本来使用后台的GP工具做的,但是处理时间比较长需要十几秒钟左右,所以研究怎么通过前台来计算.     参考下克里金例子,思路是生成要计算区域的100乘以100网格,然 ...

随机推荐

  1. Nullable<T>、Nullable、null、?修饰符的区别

    这章我们讨论一下Nullable<T>.Nullable.null.?修饰符的区别 原创文章 Nullable<T>的前世今生 讨论它们之前,我们有必要讨论一下Nullable ...

  2. 第18课-数据库开发及ado.net 连接数据库.增.删.改向表中插入数据并且返回自动编号.SQLDataReade读取数据

    第18课-数据库开发及ado.net 连接数据库.增.删.改向表中插入数据并且返回自动编号.SQLDataReade读取数据 ADO.NET 为什么要学习? 我们要搭建一个平台(Web/Winform ...

  3. mysql的密码问题

    常见问题 Access denied for user 'root'@'localhost' (using password: YES) 因密码不对而拒绝访问,再jdbc配置中 常常忽略user和密码 ...

  4. linux系统编程:cp的另外一种实现方式

    之前,这篇文章:linux系统编程:自己动手写一个cp命令 已经实现过一个版本. 这里再来一个版本,涉及知识点: linux系统编程:open常用参数详解 Linux系统编程:简单文件IO操作 /*= ...

  5. zsh: command not found: pip 解决方法

    出现zsh: command not found: xxx解决方法: 把 bash shell 中.bash_profile 全部环境变量加入zsh shell里就好 step1: Term执行 op ...

  6. mysql小试题

    1. 用户登录日志表 xes_user_login_logs 如下: (1) 检索登录超过两次的用户ID(sql语句) select user_id from vvt_ceshi group by u ...

  7. JS实现自定义排序

    定义:用本地特定的顺序来比较两个字符串. 语法:stringObject.localeCompare(target) 参数:target——要以本地特定的顺序与 stringObject 进行比较的字 ...

  8. js-ES6学习笔记-编程风格(2)

    1.那些需要使用函数表达式的场合,尽量用箭头函数代替.因为这样更简洁,而且绑定了this. 2.所有配置项都应该集中在一个对象,放在最后一个参数,布尔值不可以直接作为参数. 3.不要在函数体内使用ar ...

  9. webpack4.0在Mac下的安装配置及踩到的坑

    一.什么是webpack是一个前端资源加载/打包工具.它将根据模块的依赖关系进行静态分析,然后将这些模块按照指定的规则生成对应的静态资源.它做的事情是,分析你的项目结构,找到JavaScript模块以 ...

  10. 排错-Ad Hoc Distributed Queries组件被禁用的解决办法

    Ad Hoc Distributed Queries组件被禁用的解决办法 by:授客 QQ:1033553122 SQL Server 阻止了对组件 'Ad Hoc Distributed Queri ...