AnsweredAssumed Answered

renderingInfo

Question asked by gueniot on Jul 4, 2017
Latest reply on Jul 5, 2017 by gueniot

Hi,

I would like to display a map from data self-generated but I have the following javascript error : TypeError: this.renderingInfo.symbol is null

 

Here my complete code :

require([
"esri/views/MapView",
"esri/Map",
"esri/layers/FeatureLayer",
"esri/layers/support/Field",
"esri/geometry/Point",
"esri/renderers/UniqueValueRenderer",
"esri/symbols/SimpleMarkerSymbol",
"esri/widgets/Legend",
"esri/request",

"dojo/_base/array",
"dojo/dom",
"dojo/on",
"dojo/domReady!"
], function(MapView, Map, FeatureLayer, Field, Point,
UniqueValueRenderer, SimpleMarkerSymbol, Legend, esriRequest,
arrayUtils, dom, on
){


// Création de la couche de points
var fields = [
{
name: "ObjectID",
alias: "ObjectID",
type: "oid"
},{
name: "lemme",
alias: "lemme",
type: "string"
},{
name: "formePhonique",
alias: "formePhonique",
type: "string"
},{
name: "commune",
alias: "commune",
type: "string"
}, ,{
name: "question",
alias: "question",
type: "string"
}
];

var pTemplate = {
title: "{question}",
content: [{
type: "fields",
fieldInfos: [{
fieldName: "lemme",
label: "Lemme",
visible: true
}, {
fieldName: "formePhonique",
label: "Forme phonique",
visible: true
}, {
fieldName: "commune",
label: "Commune",
visible: true
}]
}]
};

var features = [{geometry: new Point({
x: 9.123337,
y: 42.474312,
}),
attributes: {
ObjectID: 7885,
lemme: "tumbà",
formePhonique: "tumb'a",
commune: "Moltifao",
question: "'tuer' (le cochon)"
}
},
.....
];
var map = new Map({
basemap: "gray"
});

var view = new MapView({
container: "viewDiv", // Reference to the DOM node that will contain the view
center: [9.15892639, 42.183238],
zoom: 9,
map: map // References the map object created in step 3
});

var tumbà = new SimpleMarkerSymbol({
color: getRandomColor(),
width: 10,
style: "solid"
});
var pulsà = new SimpleMarkerSymbol({
color: getRandomColor(),
width: 10,
style: "solid"
});

var defaultSymb = new SimpleMarkerSymbol({
color: "#123456",
width: 10,
style: "solid"
});

var myrenderer = new UniqueValueRenderer({
defaultSymbol: defaultSymb,
defaultLabel: "Other major roads",
field: "lemme",
visualVariables: [
{
type: "size",
field: "lemme"
}],
uniqueValueInfos: [
{
value: "tumbà", // code for interstates/freeways
symbol: tumbà,
label: "tumbà"
},
....
]
});

var lyr = new FeatureLayer({
source: features,
fields: fields,
objectIdField: "ObjectID",
geometryType: "point",
renderer: myrenderer,
spatialReference: {
wkid: 4326
},
popupTemplate: pTemplate
});

var legend = new Legend({
view: view,
layerInfos: [{
layer: lyr,
title: "'tuer' (le cochon)"
}]
});

map.add(lyr);
view.graphics.add([lyr]);

view.ui.add(legend, "bottom-left");

 

Thanks for your help!

Outcomes