title: TypeError: g is not a function
body: <p>While re-writing one of my applications from scratch (to go from legacy to AMD) I'm encountering an error which I can't figure out. It is driving me crazy. I'm probably just misspelling something or have another minor mistake, but I just can't figure out what. Any help would be highly appreciated!</p>
  
  <p>I'm still in development mode, so my code isn't that pretty at this time. You can see it live in action at here: <a href="http://tpgrf.nl/testserver/alpha/topotrainer/flevoland" rel="nofollow noreferrer">http://tpgrf.nl/testserver/alpha/topotrainer/flevoland</a></p>
  
  <p>The javascript code:</p>
  
  <pre><code>//Define area and url's  
  var currentPath = window.location.pathname.split('/');
  var AREA = currentPath[currentPath.length - 2];
  if (AREA == 'europa' || AREA == 'wereld' || AREA == 'nederland') {
      var AREAURL = AREA;
      var AREAisProvince = false;
  } else {
      AREAURL = 'nederland';
      var AREAisProvince = true;
  }; //Ondervang provincies  
  
  
  var basemapURL = window.location.protocol + "//tiles.arcgis.com/tiles/nSZVuSZjHpEZZbRo/arcgis/rest/services/Topografie_in_de_klas_" + AREAURL + "_ondergrond/MapServer";
  var contentFeatureURL = window.location.protocol + "//services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_" + AREAURL + "/FeatureServer/0";
  
  
  
  
  var CONTENT = 'cito100'; //Default to 'cito100', user can adjust manually  
  var TYPES = ''; //empty for now, will be defined later by the user  
  var TYPES = 'plaats'; //for testingunction's//  
  //  
  function generateUUID() {
      var d = new Date().getTime();
      var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
          var r = (d + Math.random() * 16) % 16 | 0;
          d = Math.floor(d / 16);
          return (c == 'x' ? r : (r &amp; 0x7 | 0x8)).toString(16);
      });
      return uuid;
  };
  
  
  //  
  //Figure something out here to detect if the user as a new or returning visitor  
  //  
  
  
  //////////////////////////////////////  
  //Create a basemap and load features//  
  //////////////////////////////////////  
  var dojoConfig = { parseOnLoad: true };
  
  
  var map;
  require(["esri/geometry/Extent", "esri/SpatialReference", "esri/map", "esri/graphic", "esri/layers/ArcGISTiledMapServiceLayer", "esri/tasks/query", "esri/tasks/QueryTask", "esri/tasks/FeatureSet", "esri/layers/GraphicsLayer", "esri/Color", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/symbols/PictureMarkerSymbol", "esri/renderers/UniqueValueRenderer", "esri/renderers/ClassBreaksRenderer",
      "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/TitlePane",
      "dojo/domReady!", "dojo/dom", "dojo/on"],
      function (Extent, SpatialReference, Map, Graphic, Tiled, Query, QueryTask, FeatureSet, GraphicsLayer, Color, SimpleMarkerSymbol, SimpleLineSymbol, PictureMarkerSymbol, UniqueValueRenderer, ClassBreaksRenderer, dom, on) {
          //@TODO: Can we actually define this on the basemap mapserver?  
          if (AREA == 'nederland' || AREAisProvince == true) {
              var initExtent = new Extent(-165715, 6453119, 1435181, 7205260, new SpatialReference({ wkid: 102100 }));
          }
          if (AREA == 'europa') {
              var initExtent = new Extent(-2827847, 2851709, 6838658, 11375669, new SpatialReference({ wkid: 102100 }));
          }
          if (AREA == 'wereld') {
              var initExtent = new Extent(-19705424, -14849545, 21700207, 21624981, new SpatialReference({ wkid: 102100 }));
          }
  
          map = new Map("map", {
              extent: initExtent
          });
  
  
          //let's add a basemap  
          var tiled = new Tiled(basemapURL);
          map.addLayer(tiled);
  
          where = 'Cito100_onderdeel=1';
          if (AREAisProvince == true) {
              where += ' AND Provincie=\'' + AREA + '\'';
          }
          map.on("load", getFeaturesToMapAndStorage(where));
  
          function getFeaturesToMapAndStorage(whereClause) {
              console.log(whereClause);
              //query the featureService  
              var query = new Query();
              query.returnGeometry = true;
              query.outFields = ["*"];
              query.outSpatialReference = new SpatialReference({ wkid: 102100 });
              query.where = whereClause;
  
              var queryTask = new QueryTask(contentFeatureURL);
  
              queryTask.on("complete", function (event) {
                  //map.graphics.clear();  
                  var featureGraphicsLayer = new GraphicsLayer();
  
  
                  //@TODO: Can't we find a way to use the symbols from the featurservice directly, instead of the url's?  
                  defaultSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 10,
              new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
              new Color([255, 0, 0]), 1),
              new Color([0, 255, 0, 0.25]));
  
                  var renderer = new UniqueValueRenderer(defaultSymbol, "Type");
                  renderer.addValue("Plaats", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_nederland/FeatureServer/0/images/89e5f81878a69f9cc0525c841f98af54", 11, 11));
                  renderer.addValue("Gebied", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_nederland/FeatureServer/0/images/165c76bd4465728a34f6d18df4a1ec03", 28, 28));
                  renderer.addValue("Water", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_nederland/FeatureServer/0/images/f9c146a401f48c4f38202e83c2e4582a", 22, 22));
                  renderer.addValue("Provincie", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_nederland/FeatureServer/0/images/7a5373d8f1dcd1ecc03cefbab687b97c", 38, 32));
                  renderer.addValue("Land", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_europa/FeatureServer/0/images/7a5373d8f1dcd1ecc03cefbab687b97c", 38, 32));
                  renderer.addValue("Werelddeel", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_wereld/FeatureServer/0/images/48f2256a49253388488d813d721c054b", 32, 38));
  
                  var features = event.featureSet.features;
                  var featureCount = features.length;
                  for (var i = 0; i &lt; featureCount; i++) {
                      var graphic = features[i];
                      featureGraphicsLayer.add(graphic);
                  }
                  featureGraphicsLayer.renderer = renderer;
                  map.addLayer(featureGraphicsLayer);
  
                  //@TODO: Update localstorage    
  
              }); //end on queryTask complete  
  
              queryTask.execute(query, queryComplete);
  
              function queryComplete() {
                  console.log("fire function queryComplete");
                  //@TODO: reset progressbar  
              }; //End function queryComplete  
  
  
          } //end function getFeaturesToMapAndStorage  
  
          //The two closing tags below are essential and close the complete DOJO part.    
      } //end function after require (AMD style)  
      ); //end require
  </code></pre>