Sha256: e0b65d8e35c668665c927ce6f61e0bb507a220d8637681762e9c36a42a685958

Contents?: true

Size: 1.9 KB

Versions: 39

Compression:

Stored size: 1.9 KB

Contents

GMaps.prototype.createControl = function(options) {
  var control = document.createElement('div');

  control.style.cursor = 'pointer';
  
  if (options.disableDefaultStyles !== true) {
    control.style.fontFamily = 'Roboto, Arial, sans-serif';
    control.style.fontSize = '11px';
    control.style.boxShadow = 'rgba(0, 0, 0, 0.298039) 0px 1px 4px -1px';
  }

  for (var option in options.style) {
    control.style[option] = options.style[option];
  }

  if (options.id) {
    control.id = options.id;
  }

  if (options.classes) {
    control.className = options.classes;
  }

  if (options.content) {
    if (typeof options.content === 'string') {
      control.innerHTML = options.content;
    }
    else if (options.content instanceof HTMLElement) {
      control.appendChild(options.content);
    }
  }

  if (options.position) {
    control.position = google.maps.ControlPosition[options.position.toUpperCase()];
  }

  for (var ev in options.events) {
    (function(object, name) {
      google.maps.event.addDomListener(object, name, function(){
        options.events[name].apply(this, [this]);
      });
    })(control, ev);
  }

  control.index = 1;

  return control;
};

GMaps.prototype.addControl = function(options) {
  var control = this.createControl(options);
  
  this.controls.push(control);
  this.map.controls[control.position].push(control);

  return control;
};

GMaps.prototype.removeControl = function(control) {
  var position = null,
      i;

  for (i = 0; i < this.controls.length; i++) {
    if (this.controls[i] == control) {
      position = this.controls[i].position;
      this.controls.splice(i, 1);
    }
  }

  if (position) {
    for (i = 0; i < this.map.controls.length; i++) {
      var controlsForPosition = this.map.controls[control.position];

      if (controlsForPosition.getAt(i) == control) {
        controlsForPosition.removeAt(i);

        break;
      }
    }
  }

  return control;
};

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
wbase-0.3.20 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.19 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.18 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.17 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.16 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.15 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.14 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.13 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.12 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.11 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.10 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.9 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.8 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.7 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.6 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.5 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.4 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.3 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.2 lib/vendor/admin/gmaps/lib/gmaps.controls.js
wbase-0.3.1 lib/vendor/admin/gmaps/lib/gmaps.controls.js