Select to view content in your preferred language

How to get lat long of an offsetted graphic layer?

834
5
03-09-2012 01:02 PM
KaitoSoto
Emerging Contributor
Say I have a shape of a point:

var shape = new esri.geometry.Point(somex, somey, new esri.SpatialReference({wkid:4326}));
var simpleMarkerSymbol = new esri.symbol.SomeSymbol(-Insert Attributes Here-).setOffset(5,5);
var graphic = new esri.Graphic(shape, simpleMarkerSymbol);

I need a way to be able to get the lat long of the graphic post-application of the offset. How do I do this? Examples appreciated.
0 Kudos
5 Replies
KaitoSoto
Emerging Contributor
Is this really impossible to do?
0 Kudos
StephenLead
Honored Contributor

var shape = new esri.geometry.Point(somex, somey, new esri.SpatialReference({wkid:4326}));
var simpleMarkerSymbol = new esri.symbol.SomeSymbol(-Insert Attributes Here-).setOffset(5,5);   
var graphic = new esri.Graphic(shape, simpleMarkerSymbol);

I need a way to be able to get the lat long of the graphic post-application of the offset


I haven't tested this, but you could try:
var long = graphic.geometry.x;
var lat = graphic.geometry.y;


I'm assuming that the offset only applies to the marker symbol, not to the graphic itself, so the geometry should be unchanged.
0 Kudos
derekswingley1
Deactivated User
Steve is right�?? use the graphic geometry's x and y to get your coordinates. The offset you're applying affects the symbol, not the actual geometry.
0 Kudos
KaitoSoto
Emerging Contributor
The issue is I want to draw a polyline from the shape to the offset point. If I can't get the lat long of the offsetted point, it won't work unless I am able to draw a shape that is always offset from the shape to the offset point. Though since working in lat longs, I'm not sure what the computation for the lat long would be if i wanted to draw a point say 5pixels up and 5 pixels left from a shape unless there is an easier way to do that.
0 Kudos
StephenLead
Honored Contributor
Hi Kaito,

Take a look at toMap(screenPoint) and toScreen(mapPoint) which may help - they convert coordinates between page and map coordinates.

You may be able to obtain the map coordinate of the graphic, convert it to page units, offset it, and convert that back to map units.

Steve
0 Kudos