Example #1
0
VizJSON.prototype.enforceGMapsBaseLayer = function (gmapsBaseType, gmapsStyle) {
  var isGmapsBaseTypeValid = _.contains(C.GMAPS_BASE_LAYER_TYPES, gmapsBaseType);
  if (this.map_provider === C.MAP_PROVIDER_TYPES.LEAFLET && isGmapsBaseTypeValid) {
    if (this.layers) {
      this.layers[0].options.type = 'GMapsBase';
      this.layers[0].options.baseType = gmapsBaseType;
      this.layers[0].options.name = gmapsBaseType;

      if (gmapsStyle) {
        this.layers[0].options.style = typeof gmapsStyle === 'string' ? JSON.parse(gmapsStyle) : gmapsStyle;
      }

      this.map_provider = C.MAP_PROVIDER_TYPES.GMAPS;
      this.layers[0].options.attribution = ''; // GMaps has its own attribution
    } else {
      log.error('No base map loaded. Using Leaflet.');
    }
  } else {
    log.error('GMaps baseType "' + gmapsBaseType + ' is not supported. Using leaflet.');
  }
};
Example #2
0
OverlaysFactory.prototype.create = function (type, data) {
  var overlayConstructor = this.constructor._constructors[type];
  if (!overlayConstructor) {
    log.log("Overlays of type '" + type + "' are not supported anymore");
    return;
  }

  data.options = typeof data.options === 'string' ? JSON.parse(data.options) : data.options;
  data.options = data.options || {};
  var overlay = overlayConstructor(data, {
    mapModel: this._mapModel,
    mapView: this._mapView,
    visView: this._visView
  });

  if (overlay) {
    overlay.type = type;
    return overlay;
  }

  return false;
};
Example #3
0
window.L = require('leaflet');

require('mousewheel'); // registers itself to $.event; TODO what's this required for? still relevant for supported browsers?
require('mwheelIntent'); // registers itself to $.event; TODO what's this required for? still relevant for supported browsers?

var cdb = require('cdb');
if (window) {
  window.cartodb = window.cdb = cdb;
}

cdb.core = {};
cdb.core.sanitize = require('./core/sanitize');
cdb.core.Template = require('./core/template');
cdb.core.Model = require('./core/model');
cdb.core.View = require('./core/view');

cdb.SQL = require('./api/sql');

cdb.createVis = require('./api/create-vis');

// log carto.js version
var logger = require('cdb.log');
logger.log('carto.js ' + cdb.VERSION);

cdb.helpers.GeoJSONHelper = require('./geo/geometry-models/geojson-helper');

module.exports = cdb;