add graphic with wrong extent

483
5
Jump to solution
12-10-2012 03:46 AM
YvanBérard
Occasional Contributor
Hi all,

recently I had a problem with the findTask, but I digged up more the problem and found that my graphic were added, but with the wrong extent.

Do you know how to solve the problem?

This is my original extent (situated in Quebec, Canada) :

var initialExtent = new esri.geometry.Extent({ 'xmin': -8034661, 'ymin': 5652797, 'xmax': -8004182, 'ymax': 5670187, 'spatialReference': new esri.SpatialReference({ wkid: 102100 }) });



But, when the event add(graphic) is fired, the graphic are added in the middle of the mediterannean sea (?!?!?!???). How could this happen? I've never seen that bug.


var graphic = new esri.Graphic(result.feature.geometry, sym); //create graphic with geometry (result.feature.geometry) and symbol (sym)         console.dir(map);         map._layers.search_result.add(graphic); //add graphic to graphics layer created above



Thank you.
0 Kudos
1 Solution

Accepted Solutions
JeffPace
MVP Alum
thats very odd but i think we are on the correct path. Whatever is generating your result, are you specifying an outSR?

View solution in original post

0 Kudos
5 Replies
JeffPace
MVP Alum
Whats the spatial reference of result.feature?
0 Kudos
YvanBérard
Occasional Contributor
wkid: 32188

And I don't know why...

it seems that this spatial reference is created automatically when there is a map._layers.search_result.add(graphic);

How could I change the spatial reference of a graphic layer???
0 Kudos
JeffPace
MVP Alum
thats very odd but i think we are on the correct path. Whatever is generating your result, are you specifying an outSR?
0 Kudos
YvanBérard
Occasional Contributor
No I'm not using an outSpatialReference. Because I thought my graphic would automatically use my map.extent and my map SR.


I just added this to my findTask parameters and it worked well.

findParams.outSpatialReference = new esri.SpatialReference({ wkid: 102100 });
0 Kudos
JeffPace
MVP Alum
No I'm not using an outSpatialReference. Because I thought my graphic would automatically use my map.extent and my map SR.


Only if the SR is undefined, in this case it looks like it is defined by the request/response and that is where the problem is.
0 Kudos