标签:java 博文 view try enc isp pat cgi omr
坐标系
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
标签:java 博文 view try enc isp pat cgi omr
原文地址:https://www.cnblogs.com/telwanggs/p/10107957.html