Sharing common function between web maps.

434
1
04-03-2012 01:00 AM
CliveSwan
Occasional Contributor II
Hi,

We have 3 map services that share common functions e.g. function init(); FinaliseMap = function()....etc.
The aim is to put the common code into a single file and call the functions as required.

I have tried moving the code to a common file then calling the function from Map A for example.
Get an error calling them??

For example.

I put  function COL.init() in col_common_SHARED.js
Then tried to call function COL.init() in Map Service A (mapA.js).


mapA.js
var function init() = COL.init;

Any suggestions what is wrong AND what I should be doing??
Appreciate any assistance.
0 Kudos
1 Reply
derekswingley1
Frequent Contributor

I put  function COL.init() in col_common_SHARED.js
Then tried to call function COL.init() in Map Service A (mapA.js).

mapA.js
var function init() = COL.init;


That last line doesn't make sense. If you want to create a variable that points to the COL.init function, you would do this: 
var init = COL.init;


Referring to a function by name gets you a reference to it. Adding parentheses immediately after a function name invokes the function.
0 Kudos