0

Using ESRI ArcGIS javascript api v 3.16

I programmatically add a graphic to my map, which works fine, for example :

var pnt = map.graphics.add(new Graphic(evt.mapPoint, stopSymbol));

I need to fire an event handler when this pnt is drawn on the map. I have tried map.on("graphic-add"), but it does not fire for above.

I've also tried to fire a reposition event with map.centerAt(pnt.geometry), but also nothing fires .

Any advice ?

1

After loading your map just associate the event to the default map graphicLayer :

map.on("load",function(){
    map.graphics.on("graphic-add",function(evt) {
        //some stuff after adding graphic 
        alert("graphic added);
    });
});
0

map.graphics is an instance of a GraphicsLayer, so you should be able to listen for an event at the GraphicsLayer level, something like:

map.graphics.on('update-end', function(evt) { 
    // do something here!
});
  • You are welcome Dubya! Don't forget to mark this as the "answer" if it's what solved your problem. – GavinR Apr 1 '16 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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