javascript smart mapping color ramp

4198
6
08-19-2015 11:02 AM
DavidChevrier
Occasional Contributor II

Hi,

  I'm using the new smartMapping createClassedColorRender, but don't like the color ramp options that come for the default basemaps.  How can I change the color ramp to a simple dark blue to red ramp?

This is how I'm creating the renderer now (its for a feature layer)

Thanks,

-dave

smartMapping.createClassedColorRenderer({

  layer: featureLayer,

  field: fieldName,

  basemap: "oceans",

  classificationMethod: "natural-breaks",

  numClasses: 10

}).then(function (response) {

  featureLayer.setRenderer(response.renderer);

  featureLayer.redraw();

  createLegend(map, featureLayer, fieldName);

});

map.addLayer(featureLayer);

0 Kudos
6 Replies
ChrisSmith7
Frequent Contributor

It seems that you might be able to using scheme:

esri/renderers/smartMapping | API Reference | ArcGIS API for JavaScript

I wasn't able to pull an example, though - looking into that now...

0 Kudos
DavidChevrier
Occasional Contributor II

I saw that and was thinking the same thing.  However I wasn't about exactly how to do that.  An example would be awesome though!

0 Kudos
ChrisSmith7
Frequent Contributor

I quickly gave a stab at what I think it's expecting based on the documentation, but it's throwing an error - "Error: smartMapping.createClassedColorRenderer: unable to find suitable colors for number of classes."

ArcGIS API for JavaScript Sandbox

 function createRenderer(field) {
  //smart mapping functionality begins
  smartMapping.createClassedColorRenderer({
    layer: layer,
    field: field,
    basemap: map.getBasemap(),
    classificationMethod: "quantile",
    scheme: 
   {
  primaryScheme: 
  { 
  colorsForClassBreaks: 
  {
  numClasses: 5,
  colors:
  [
  new Color("#FFE6E6"),
  new Color("#FFB2B2"),
  new Color("#FF8080"),
  new Color("#FF4D4D"),
  new Color("#FF1919")
  ]
  }
  }
   }
  }).then(function (response) {
    layer.setRenderer(response.renderer);
    layer.redraw();
    createLegend(map, layer, field);
  });
 }
0 Kudos
SatyanarayanaNarmala
New Contributor III

Hi all

i too have same problem with colorramp in smart mapping, as well as how to change the range values.

0 Kudos
SteveLewis
Occasional Contributor

We've recently implemented  SmartMapping in the JavaScript API.  Super cool 

We're also stuck and unable to change color ramp (except for using base map) in the JavaScript API?   Anybody having any luck in the red to blue?

0 Kudos
DavidChevrier
Occasional Contributor II

I'm glad other people are running into this problem.  I haven't been able to come up with a solution, but will need to soon.  I'm hoping someone from esri's development team chimes in.

0 Kudos