Select to view content in your preferred language

Color Palette on graphics

1043
4
09-15-2014 09:14 AM
IbrahimHussein
Deactivated User

Hello,

example - jsFiddle

Answer - jsFiddle

If you look at the example above, when you click a text field a color Palette comes up; is there an easy way to do this for a graphic (eclipse, triangle...) as well?

edit - Answer -

  var myPalette = new ColorPalette({

  palette: "7x10",

  onChange: function(val){

  if(grfx.geometry.type==="point")

  {return;}

  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(val);

  var r = parseInt(result[1], 16)

  var g = parseInt(result[2], 16)

  var b = parseInt(result[3], 16)

  var symbol =  new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,

  new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,

  new Color([0,0,0]), 2),new Color([r,g,b,0.75]));

  grfx.setSymbol(symbol);

  }

  }, "colorPal").startup();

On graphic click, I set the symbol to the color palette.

0 Kudos
4 Replies
PaulCrickard1
Deactivated User

You have the reference to ColorPalette so the textbox probably uses the dojo widget. You could hide a <div> with the colorpalette widget, then on an event (edit a marker) it becomes visible and the color chosen updates the graphic.

dijit.ColorPalette — The Dojo Toolkit - Reference Guide

0 Kudos
IbrahimHussein
Deactivated User

Thanks for the reply. I actually started to do that, that's why there's a reference to colorPalette. If  the reference is removed, it still shows up for the Text Box.

0 Kudos
TimWitt2
MVP Alum

Hey Ibrahim,

I have created this Javascript API - Advanced Draw widget

Maybe that can help you

Tim

IbrahimHussein
Deactivated User

thanks, there were some cool stuff in there that I can see myself using.

0 Kudos