monzay

beginner: changing map extent on click

Discussion created by monzay on Nov 3, 2011
Latest reply on Nov 3, 2011 by monzay
I want the map extent to change by clicking on some text. I'm using the example Add Dynamic Map and I have added the following code

function myzoom() {
          
        var axtent = new esri.geometry.Extent(55.6153456, 5.7191691, 105.6673614, 37.0016790, map.SpatialReference);
        map.setExtent(axtent);
        
        }


I have tried placing it both outside of the init function and inside the init function. In both cases I get an error when I call it
<p id="test" onClick="myZoom();">click for zoom</p>


If I add an alert function outside of the init function
  function nTest(){
   alert("test2");
  }


and call it from here 
<p id="test2" onClick="nTest();">click for alert</p>


it works.

Why?


- Mike

Outcomes