FeatureLayer
dorianboulch opened this issue · comments
I can't find how to add a FeatureLayer to the map, can you help me ?
Thanks
@dorianboulch, I should have an example or two of adding FeatureLayers into a map soon for #19. However, basically what you need to do is use the EsriLoaderService to load in the ESRI modules that you need, create the FeatureLayer, and add it to your map. It would look something like this:
this.esriLoader.loadModules([
'esri/symbols/SimpleMarkerSymbol',
'esri/Color',
'esri/layers/FeatureLayer',
'esri/renderers/SimpleRenderer',
'esri/PopupTemplate'
]).then(([
SimpleMarkerSymbol,
Color,
FeatureLayer,
SimpleRenderer,
PopupTemplate
]: [
__esri.SimpleMarkerSymbolConstructor,
__esri.ColorConstructor,
__esri.FeatureLayerConstructor,
__esri.SimpleRendererConstructor,
__esri.PopupTemplateConstructor
]) => {
const featureLayer = new FeatureLayer({
fields: fields,
objectIdField: 'ObjectID',
renderer: new SimpleRenderer({
symbol: new SimpleMarkerSymbol({ color: new Color(color) })
}),
spatialReference: {
wkid: 4326
},
geometryType: 'point',
popupTemplate: popupTemplate,
title: title,
id: id,
source: url
});
this.map.add(featureLayer);
});
Again, keep an eye on #19 as we will be adding some examples there.
Great, it works !
Thank you a lot