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 use ArcGis Javascript api 3.2. I have a symbol:

candidateSymbol=new esri.symbol.PictureMarkerSymbol('image/PushPin.png', 30, 30);

I want to center it when it is being clicked.

PS: There will be many such symbols on the map. I want to center the screen on the symbol that is being clicked.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I solved it by doing the following.

dojo.connect(map.graphics, "onClick", function(evt) {         
      var g=evt.graphic.geometry;
      map.centerAt(g);      
});

But it is important to make sure that this part of the code is placed after the "map" is instantiated. Failing to do so will through you a js error that "map object not found".

PS: candidateSymbol was part of the graphics layer.

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.