Skip to content
Snippets Groups Projects
shapeloader_static.js 939 B
Newer Older
Brandon Bergren's avatar
Brandon Bergren committed
 * @file
 * GMap Shape Loader
 * Static Shapes.
 * This is a simple marker loader to read markers from the map settings array.
 * Commonly used with macros.
 */

Brandon Bergren's avatar
Brandon Bergren committed
/*global $, Drupal */

// Add a gmap handler
Brandon Bergren's avatar
Brandon Bergren committed
Drupal.gmap.addHandler('gmap', function (elem) {
  var obj = this;
  if (obj.vars.shapes) {
    // Inject shapes during init.
Brandon Bergren's avatar
Brandon Bergren committed
    obj.bind('init', function () {
      // We need to move the incoming shapes out of the way,
      // because addshape will readd them, causing an infinate loop.
      // Store the shapes in s and reset obj.vars.shapes.
      var s = obj.vars.shapes;
      obj.vars.shapes = [];
Brandon Bergren's avatar
Brandon Bergren committed
      $.each(s, function (i, shape) {
        if (!shape.opts) {
          shape.opts = {};
        }
        // TODO: style props?
        // And add it.
Brandon Bergren's avatar
Brandon Bergren committed
        obj.change('prepareshape', -1, shape);
        obj.change('addshape', -1, shape);
Brandon Bergren's avatar
Brandon Bergren committed
      obj.change('shapesready', -1);