Zoom in on click of an icon on the map

1092
6
03-10-2013 07:07 AM
SaiDake
New Contributor
I have a map rendered and have used some custom icons dropped on the map. Can i know what needs to be done onclick of the icon so that map zooms in at particular location and drops few more icons (have written the code for dropping the icons)?  Need the code just to find out the onclick of an icon. Need a listner for onclick of a dropped icon on the map.

My Code:-
plotAddressId= function plotAddressId(addressId, state) {
           addressIdQuery = new esri.tasks.Query();
            addressIdQuery.returnGeometry = true;
            addressIdQuery.where = "ADDRESS_KEY = '" + state + addressId + "'";
            addressIdQueryTask.execute(addressIdQuery, function(results) {
              var geom = results.features[0].geometry;
              var graphic = new esri.Graphic(geom, locationSymbol);
              locationGraphicsLayer.add(graphic);
              zoomToLocations();
            });
          }
0 Kudos
6 Replies
RahulMetangale1
Occasional Contributor II
Sai,

try centerAndZoom(mapPoint, levelOrFactor) function. Here is the link for additional reference:
http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/map.html#Map/centerAndZoom
0 Kudos
SaiDake
New Contributor
Thx Rahul...im looking for how to write an event listner on click of an icon(only icons). I have the code to zoom in. Thx!!
0 Kudos
SunilPalkar
Occasional Contributor
Thanks Rahul

It works for me as well in different condition : )

thanks

Sai,

try centerAndZoom(mapPoint, levelOrFactor) function. Here is the link for additional reference:
http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/map.html#Map/centerAndZoom
0 Kudos
SaiDake
New Contributor
there is an onclick event for graphics....but it doesnt work.
dojo.connect(map.graphics, "onClick", function(e) {alert("hi");});
0 Kudos
RahulMetangale1
Occasional Contributor II
Sai,

From code it appears that you are adding graphics to locationGraphicsLayer.
So try
dojo.connect(locationGraphicsLayer, "onClick", function(e) {alert("hi");});
0 Kudos
SaiDake
New Contributor
Awesome. thx Rahul!! It worked.
0 Kudos