TypeError: g is not a function

07-26-2014 07:26 AM
New Contributor III

Hi There!

While re-writing one of my applications from scratch (to go from legacy to AMD) I'm encountering an error which I can'f 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!

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.

The javascript 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 AREAisProvince = false;


  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&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);



  where = 'Cito100_onderdeel=1';

  if(AREAisProvince == true){

  where += ' AND Provincie=\''+AREA+'\'';


  map.on("load", getFeaturesToMapAndStorage(where));


  function getFeaturesToMapAndStorage(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) {


   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/Fe...", 11, 11));

   renderer.addValue("Gebied", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_nederland/Fe...", 28, 28));

   renderer.addValue("Water", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_nederland/Fe...", 22, 22 ));

   renderer.addValue("Provincie", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_nederland/Fe...", 38, 32 ));

   renderer.addValue("Land", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_europa/Featu...", 38, 32 ));

   renderer.addValue("Werelddeel", new PictureMarkerSymbol("https://services.arcgis.com/nSZVuSZjHpEZZbRo/ArcGIS/rest/services/Topografie_in_de_klas_wereld/Featu...", 32, 38));


   var features = event.featureSet.features;

   var featureCount = features.length;

   for (var i = 0; i < featureCount; i++) {

  var graphic = features;



   featureGraphicsLayer.renderer = renderer;



//@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

0 Kudos
1 Reply
New Contributor III

It has been solved in the mean time, on stack exchange. See javascript - TypeError: g is not a function - Stack Overflow‌ for more detail!

0 Kudos