Select to view content in your preferred language

write and load custom dojo class

2825
1
08-18-2014 01:41 PM
BhavinSanghani
Occasional Contributor II

How can I write my custom dojo class that I can add with require([..]) like other ArcGIS JS classes? I created one module (or class) like following so, I can keep some of the code in this class for reusability.

 

//file name for following module let's say ESRI.js

 

define(['esri/layers/GraphicsLayer',

  'esri/symbols/SimpleMarkerSymbol',

  'esri/symbols/SimpleFillSymbol',

  'esri/symbols/SimpleLineSymbol',

  'esri/symbols/TextSymbol',

  'esri/Color',

  'esri/symbols/Font',

  'esri/geometry/Circle',

  'esri/geometry/Polygon',

  'esri/units',

  'esri/tasks/query',

  'esri/tasks/QueryTask'],

  function(GraphicsLayer, SimpleMarkerSymbol, SimpleFillSymbol, SimpleLineSymbol, TextSymbol, Color, Font,

  Circle, Polygon, Units, Query, QueryTask){

return {

  getMap: function() {

  return this.map;

  },

  setMap: function(map) {

  this.map = map;

  }

});

0 Kudos
1 Reply
YousefQuran
Occasional Contributor

Did you check this article from esri guide? It may help you in writing a class.

0 Kudos