title: ArcGIS API - call function onClick()
body: <p>I have managed to get my tiled maps working using the ArcGIS javascript API. However, I want to be able to switch layers (showing different years). I created a function that will do this:</p>
  
  <pre><code>require(["esri/map",
      "esri/layers/ArcGISTiledMapServiceLayer",
      "esri/geometry/Point",
      "esri/SpatialReference",
      "dojo/domReady!"],
      function (Map, Tiled, Point, SpatRef) {
  
  ... 
  
          function veranderTiled(jaar){
              map_Thema_2.removeAllLayers();
              tiled = new Tiled(
              "http://tiles.arcgis.com/tiles/nSZVuSZjHpEZZbRo/arcgis/rest/services/Historische_tijdreis_"+jaar+"/MapServer");
              map_Thema_2.addLayer(tiled);
          }
  
          ... 
  
      });
  </code></pre>
  
  <p>I want to call this function when I, say, press a button at a random place on my page. Like this:</p>
  
  <pre><code>&lt;input name="" type="button" onClick="veranderTiled(2015)" value="Ander jaar" /&gt;
  </code></pre>
  
  <p>The function itself works fine, but I cannot seem to call it from anywhere outside of the require(...) part. I am not sure how javascript handles such accessibility (mostly used to C++), but I do wonder what I should change in order to be able to call this function from outside this particular script.</p>
  
  <p>Edit: as expected, the console returns that the function is not defined. Is there a way to point it to the right location (something like map.veranderTiled(2015)?)</p>