1、通过source构建FeatureLayer
const point = {
type: 'point',
longitude: 114.384697,
latitude: 30.669599,
spatialReference: { wkid: 4326 },
};
let graphic = new Graphic({
geometry: point,
attributes: { name: '123' },
});
let graphicsLayer = new GraphicsLayer();
graphicsLayer.add(graphic);
const featureLayer = new FeatureLayer({
source: graphicsLayer.graphics,
fields: [
{
name: 'ObjectID',
alias: 'ObjectID',
type: 'oid',
},
{
name: 'name',
alias: 'name',
type: 'string',
},
],