ReferenceError: using google Maps API .

ReferenceError: using google Maps API .

hey guys i am trying to build a small custom map library and i have extrated most of the code into Mapster.js file and i use my script.js file to call all the functions from Mapster.js . 

I have a small problem , i have this below line in my scripts.js file : 

  1. infoWindow.open(map.gMap , marker);
now in my mapster.js i have the following function : 

  1. addMarker : function(opts){
  2. var marker;
  3. opts.position = {
  4. lat : opts.lat,
  5. lng : opts.lng
  6. marker = this._createMarker(opts);
  7. if (opts.event) {
  8. this._on({
  9. obj : marker,
  10. event : opts.event.name,
  11. callback : opts.event.callback
  12. });
  13. }
  14. return marker;
  15. },
see that it is returning marker , yet in my script.js file , when i run the programme , i get an error :

  1. ReferenceError: marker is not defined
Why is that ?? 

The line of difficulty in my script.js file can be found on the following link : 

  1. scripts.js 
the function can be found in my Mapster.js file : 


I'd really appreciate any help , Thanks .