cannot render a thematic map, color wont show.
Hi trying to create a thematic map for a feature Layer. Here is what I did.
I. created a map.
2.Created a basemap layer and added it to the map.
3.created a feature layer and added it to the map.
4.then tried to use the smartMapping.createClassedColorRender ( I set baseMap like baseMap:map).
5.what I get is I only see the featurelayer boudries with some color. but the featureLayer polygons are not colored.
may be in step 4. I did not set my baseMap layer correctly(do not know how to do it). Can any one help me, what my mistake is.
I used the following as an example from ArcGIS javascript samples.
Smart Mapping - Render class breaks with color | ArcGIS API for JavaScript
Here is the code.
showThematicMap_back:function()
{
//global vars
var layer, legend;
var controller = this;
require([
"esri/map",
"esri/dijit/PopupTemplate",
"esri/layers/FeatureLayer",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/dijit/Legend",
"esri/renderers/smartMapping",
"dojo/_base/array",
"dojo/dom",
"dojo/dom-construct",
"dojo/data/ItemFileReadStore",
"dijit/form/FilteringSelect",
"esri/Color",
"dojo/parser",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dojo/domReady!"
], function (
Map,
PopupTemplate,
FeatureLayer,
ArcGISDynamicMapServiceLayer,
Legend,
smartMapping,
array,
dom,
domConstruct,
ItemFileReadStore,
FilteringSelect,
Color,
parser
) {
parser.parse();
var mapPageController = controller.get('controllers.mapPage');
var map = mapPageController.get('map');
//select the filed Name
var fieldName = "UNIT";
var outFields = ["UNIT"];
//create popup for template
//label is just a text field that apprears on template
var popupTemplate = new PopupTemplate({
title: "{UNIT}",
fieldInfos: [{
"fieldName": fieldName,
"label": fieldName,
"visible": true,
"format": {
places: 0,
digitSeparator: true
}
}],
showAttachments: true
});
layer = new FeatureLayer("http://memgisdev.memphis.ad/arcgis/rest/services/DPD/Boundaries2010UTM16N/MapServer/0", {
"id": "Washington",
"infoTemplate": popupTemplate,
"mode": FeatureLayer.MODE_SNAPSHOT,
"outFields": outFields,
"opacity": 0.8
});
//set Definition expression to filter the features you want to show
//layer.setDefinitionExpression("STATE_NAME='Washington'");
map.addLayer(layer);
layer.on("load", function () {
createRenderer(fieldName);
});
function createRenderer(field) {
//smart mapping functionality begins
smartMapping.createClassedColorRenderer({
layer: layer,
field: field,
basemap:map,
classificationMethod: "natural-breaks",
numClasses: 10
}).then(function (response) {
layer.setRenderer(response.renderer);
layer.redraw();
createLegend(map, layer, field);
});
}
//Create a legend
function createLegend(map, layer, field) {
//If applicable, destroy previous legend
if (legend) {
legend.destroy();
domConstruct.destroy(dom.byId("legendDiv"));
}
// create a new div for the legend
var legendDiv = domConstruct.create("div", {
id: "legendDiv"
}, dom.byId("legendWrapper"));
legend = new Legend({
map: map,
layerInfos: [{
layer: layer,
title: "Census Attribute: " + field
}]
}, legendDiv);
legend.startup();
}
});
},