I'm developing a simple application where I have a map and for each user who logs a point is added on the map. I can not create the click event when I click on one of these points and open information about it.
Solved! Go to Solution.
You simply add the click event to the GraphicsLayer that you're adding your points.
var GLayer = new GraphicsLayer();
GLayer.on("click", runClickEvent);
function runClickEvent(evt){
//do something with the event
}
There is another way to do this, in addition. When you construct the graphic, you can add an InfoTemplate (in 3.x) or PopupTemplate (in 4.x). See this sample that shows how to incorporate the attributes and PopupTemplate into a graphics that is added to a map (in this case, the line).
The graphic itself can't get a click event, but you have to add that graphic to a layer, which does have a click event. Simply listen to the click event for that layer.
got it. and how I do it?
You simply add the click event to the GraphicsLayer that you're adding your points.
var GLayer = new GraphicsLayer();
GLayer.on("click", runClickEvent);
function runClickEvent(evt){
//do something with the event
}
There is another way to do this, in addition. When you construct the graphic, you can add an InfoTemplate (in 3.x) or PopupTemplate (in 4.x). See this sample that shows how to incorporate the attributes and PopupTemplate into a graphics that is added to a map (in this case, the line).