cliveswan

Centre map

Discussion created by cliveswan on Mar 13, 2012
Latest reply on Mar 15, 2012 by cliveswan
Hi,

I want the map to centre the map, when the user clicks the map.
I have added a line to center the map, is not working??

The code is below, any suggestions???

>>>>>>>>>>>>>>>>>>>>>>>>>>>
//Zoom to the parcel when the user clicks a row
function onRowClickHandler(evt) {

    var foundItem = grid.getItem(evt.rowIndex).obj_ID;
    var selectedItem;

    dojo.forEach(map.graphics.graphics, function(graphic) {
        if((graphic.attributes) && graphic.attributes.OBJECTID === foundItem[0]) {
            selectedItem = graphic;

            switch (graphic.geometry.type) {
                case "point":
                    graphic.setSymbol(pictureMarkerSymbol);
                    break;
                case "polyline":
                    graphic.setSymbol(selectedLineSymbol);
                    break;
                case "polygon":
                    graphic.setSymbol(selectedPolySymbol);
                    break;
            }
        }
    });
    var selectedItemExtent = selectedItem._extent.expand(0.2);
    map.setExtent(selectedItemExtent);
    ///map.centerAndZoom(selectedItemExtent, 0.5);
    map.centerAt(selectedItemExtent);

Outcomes