Select to view content in your preferred language

(evt.graphic.symbol.color) what is false here?

953
5
Jump to solution
02-02-2012 09:46 AM
CesarRevilla
Regular Contributor
Hello,

I want to use this event.graphic color in a new Style. The next code still not working:

What is wrong?

function Highlight(evt){
        evt.graphic.setSymbol(new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, outline, evt.graphic.symbol.color));
}

Have anyone an Idea?

Best Regards,
orzundher
0 Kudos
1 Solution

Accepted Solutions
CesarRevilla
Regular Contributor
Hi swingley,

thank you for this answer, I found a solution to this problem.

Problem: The event information content a esri.Graphic with an undefined symbol property (attributes, geometry and others are defined).
Im not shure if its normal for other map configurations, its only not confortable.

Solution:
var actualColor = event.graphic.getDojoShape().getFill();

actualColor is a dojo.Color object, its enough for me.


Thank you for your support,
orzundher

View solution in original post

0 Kudos
5 Replies
CesarRevilla
Regular Contributor
let me reiterate what my problem is:

I get the error that symbol is undefined in esri.graphic.symbol
I am trying to do this:

dojo.connect(map, 'onClick', Hilight);
--------
and in function Hilight()
var thiscolor = evt.graphic.symbol.color;
const outline = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2); 
evt.graphic.setSymbol(new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, outline, thiscolor));

my question is:
why does evt.graphic contain an undefined value for symbol?
it is supposed to get the graphic object from the server and it is showing the color of the object when drawing the map.
I want to get the color of the object!
Can anyone suggest how I can get the color of the object that I clicked?

Thanks,
orzundher
0 Kudos
derekswingley1
Deactivated User
When your onClick fires, check to make sure the object that gets passed to your handler has a property name graphic, that graphic has a property named symbol and that symbol has a property named color. The easiest/best way to do this is with hasOwnProperty.

Depending how your app is set up, it might be better to put your onClick handler directly on your graphicsLayer rather than on your map.
0 Kudos
CesarRevilla
Regular Contributor
Hi swingley,

thank you for this answer, I found a solution to this problem.

Problem: The event information content a esri.Graphic with an undefined symbol property (attributes, geometry and others are defined).
Im not shure if its normal for other map configurations, its only not confortable.

Solution:
var actualColor = event.graphic.getDojoShape().getFill();

actualColor is a dojo.Color object, its enough for me.


Thank you for your support,
orzundher
0 Kudos
derekswingley1
Deactivated User
Glad you found a solution!
0 Kudos
CesarRevilla
Regular Contributor
graphic.getDojoShape() works not with QUERYRESULTS.features[0] Graphic.

var queryTask = new esri.tasks.QueryTask("..................");
var query = new esri.tasks.Query();

query.where = "....................";
query.returnGeometry = true;

queryTask.execute(query, functionX);

function funcitonX(QUERYRESULTS) {
  shape = QUERYRESULTS.features[0].getDojoShape(); //here hangs up!
}



Thanks for your Help,
orzundher
0 Kudos