Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am using ArcGis Javascript API 3.2. After instantiating a Point, PictureMarkerSymbol, attribite and an InfoTemplate, I use this code to plot a point on the map.

var graphic= new esri.Graphic(candidatePoint,candidateSymbol,attr,infoTemplate);
map.graphics.add(graphic);

I want to retrieve the point behind the graphic when it is being clicked. How will I do it?

Thanks, Prasanna

share|improve this question
    
Do you want it in the Map's Coordinate System or the display's coordinate system? –  Devdatta Tengshe Jan 21 '13 at 11:42

2 Answers 2

up vote 1 down vote accepted

Set up an onClick event listener for the graphics layer. The event that fires has a graphic property that give you access to the graphic that was clicked. From the graphic, you can get to the geometry, symbol, attributes and infoTemplate. The code would look something like this:

dojo.connect(map.graphics, "onClick", function(evt) {
  console.log("clicked graphic: ", evt.graphic);
});
share|improve this answer
candidatePoint.x, candidatePoint.y

esri.geometry.toScreenGeometry(extent, width, height, screenGeometry)
// esri.geometry.toScreenGeometry(map.extent, map.width, map.height, candidatePoint)

esri.geometry.geographicToWebMercator(geometry)
// esri.geometry.geographicToWebMercator(candidatePoint)

esri.geometry.webMercatorToGeographic(geometry)
// esri.geometry.webMercatorToGeographic(candidatePoint)

http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/#namespace_geometry

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.