From e1e928733f1aaa81e2aeaeaf4deee90afe9e4219 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Tue, 9 Dec 2014 17:59:19 +0100 Subject: [PATCH] Make gmaps check at high level --- lib/torque/gmaps/CanvasLayer.js | 3 --- lib/torque/gmaps/canvas_tile_layer.js | 4 ---- lib/torque/gmaps/gmaps_tileloader_mixin.js | 9 +-------- lib/torque/gmaps/index.js | 9 ++++++--- lib/torque/gmaps/torque.js | 16 +++++----------- 5 files changed, 12 insertions(+), 29 deletions(-) diff --git a/lib/torque/gmaps/CanvasLayer.js b/lib/torque/gmaps/CanvasLayer.js index e45bf71..c158b7d 100755 --- a/lib/torque/gmaps/CanvasLayer.js +++ b/lib/torque/gmaps/CanvasLayer.js @@ -29,7 +29,6 @@ * @param {CanvasLayerOptions=} opt_options Options to set in this CanvasLayer. */ -if(typeof(google) !== 'undefined' && typeof(google.maps) !== 'undefined') { function CanvasLayer(opt_options) { /** * If true, canvas is in a map pane and the OverlayView is fully functional. @@ -504,5 +503,3 @@ CanvasLayer.prototype.scheduleUpdate = function() { }; module.exports = CanvasLayer; - -} diff --git a/lib/torque/gmaps/canvas_tile_layer.js b/lib/torque/gmaps/canvas_tile_layer.js index 3ac56ba..1fdc7fd 100644 --- a/lib/torque/gmaps/canvas_tile_layer.js +++ b/lib/torque/gmaps/canvas_tile_layer.js @@ -4,8 +4,6 @@ ==================== */ -if(typeof(google) !== 'undefined' && typeof(google.maps) !== 'undefined') { - function CanvasTileLayer(canvas_setup, render) { this.tileSize = new google.maps.Size(256, 256); this.maxZoom = 19; @@ -96,5 +94,3 @@ CanvasTileLayer.prototype.releaseTile = function (tile) { }; module.exports = CanvasTileLayer; - -} diff --git a/lib/torque/gmaps/gmaps_tileloader_mixin.js b/lib/torque/gmaps/gmaps_tileloader_mixin.js index 130c1f2..a0c6a6c 100644 --- a/lib/torque/gmaps/gmaps_tileloader_mixin.js +++ b/lib/torque/gmaps/gmaps_tileloader_mixin.js @@ -1,6 +1,3 @@ -module.exports = function(torque) { -if(typeof(google) !== 'undefined' && typeof(google.maps) !== 'undefined') { - function GMapsTileLoader() { } @@ -205,8 +202,4 @@ GMapsTileLoader.prototype = { } -torque.GMapsTileLoader = GMapsTileLoader; - -} - -} \ No newline at end of file +module.exports = GMapsTileLoader; diff --git a/lib/torque/gmaps/index.js b/lib/torque/gmaps/index.js index 149cddd..bc5ae27 100644 --- a/lib/torque/gmaps/index.js +++ b/lib/torque/gmaps/index.js @@ -1,3 +1,6 @@ -module.exports = function(torque) { - require('./torque')(torque); -}; +var gmaps = {}; +if (typeof google !== 'undefined' && typeof google.maps !== 'undefined') { + gmaps = require('./torque'); + gmaps.GMapsTileLoader = require('./gmaps_tileloader_mixin'); +} +module.exports = gmaps; diff --git a/lib/torque/gmaps/torque.js b/lib/torque/gmaps/torque.js index c4ef0c4..9e35e42 100644 --- a/lib/torque/gmaps/torque.js +++ b/lib/torque/gmaps/torque.js @@ -1,12 +1,8 @@ -module.exports = function(torque) { - -if(typeof(google) !== 'undefined' && typeof(google.maps) !== 'undefined') { var carto = require('carto'); var CanvasLayer = require('./CanvasLayer'); var CanvasTileLayer = require('./canvas_tile_layer'); - -require('./gmaps_tileloader_mixin')(torque); +var GMapsTileLoader = require('./gmaps_tileloader_mixin'); function GMapsTorqueLayer(options) { var self = this; @@ -61,7 +57,7 @@ function GMapsTorqueLayer(options) { */ GMapsTorqueLayer.prototype = torque.extend({}, CanvasLayer.prototype, - torque.GMapsTileLoader.prototype, + GMapsTileLoader.prototype, torque.Event, { @@ -373,9 +369,7 @@ GMapsTiledTorqueLayer.prototype = torque.extend({}, CanvasTileLayer.prototype, { }); -torque.GMapsTiledTorqueLayer = GMapsTiledTorqueLayer; -torque.GMapsTorqueLayer = GMapsTorqueLayer; - -} - +module.exports = { + GMapsTiledTorqueLayer: GMapsTiledTorqueLayer, + GMapsTorqueLayer: GMapsTorqueLayer };