Merge branch 'master' into aequus
This commit is contained in:
commit
30e7f3fca9
4
NEWS
4
NEWS
@ -1,6 +1,10 @@
|
||||
2.11.3
|
||||
- Limited sprite radius to a maximum of 255px
|
||||
- Fixed custom marker-file functionality in Firefox
|
||||
2.11.2
|
||||
- Added error handling to Torque
|
||||
- Fixed 'remove' event triggering when removing a Torque layer.
|
||||
- Value is now capped at 255 instead of performing modulo on higher values.
|
||||
2.11.1
|
||||
- Adapts usage of marker-opacity to Mapnik's functionality
|
||||
- Added getValueForBBox to TorqueLayer's API
|
||||
|
14
dist/torque.full.js
vendored
14
dist/torque.full.js
vendored
File diff suppressed because one or more lines are too long
96
dist/torque.full.uncompressed.js
vendored
96
dist/torque.full.uncompressed.js
vendored
@ -669,6 +669,7 @@ module.exports.TorqueLayer = TorqueLayer;
|
||||
// types
|
||||
var types = {
|
||||
Uint8Array: typeof(global['Uint8Array']) !== 'undefined' ? global.Uint8Array : Array,
|
||||
Uint8ClampedArray: typeof(global['Uint8ClampedArray']) !== 'undefined' ? global.Uint8ClampedArray: Array,
|
||||
Uint32Array: typeof(global['Uint32Array']) !== 'undefined' ? global.Uint32Array : Array,
|
||||
Int16Array: typeof(global['Int16Array']) !== 'undefined' ? global.Int16Array : Array,
|
||||
Int32Array: typeof(global['Int32Array']) !== 'undefined' ? global.Int32Array: Array
|
||||
@ -1613,6 +1614,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
||||
|
||||
this.provider = new this.providers[this.options.provider](this.options);
|
||||
this.renderer = new this.renderers[this.options.renderer](this.getCanvas(), this.options);
|
||||
this.renderer.options.errorCallback = this.options.errorCallback;
|
||||
|
||||
// this listener should be before tile loader
|
||||
this._cacheListener = google.maps.event.addListener(this.options.map, 'zoom_changed', function() {
|
||||
@ -1643,6 +1645,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
||||
},
|
||||
|
||||
setSQL: function(sql) {
|
||||
if (this.provider.options.named_map) throw new Error("SQL queries on named maps are read-only");
|
||||
if (!this.provider || !this.provider.setSQL) {
|
||||
throw new Error("this provider does not support SQL");
|
||||
}
|
||||
@ -1787,6 +1790,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
||||
* set the cartocss for the current renderer
|
||||
*/
|
||||
setCartoCSS: function(cartocss) {
|
||||
if (this.provider.options.named_map) throw new Error("CartoCSS style on named maps is read-only");
|
||||
var shader = new carto.RendererJS().render(cartocss);
|
||||
this.shader = shader;
|
||||
if (this.renderer) {
|
||||
@ -1815,6 +1819,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
||||
},
|
||||
|
||||
onRemove: function() {
|
||||
this.fire('remove');
|
||||
CanvasLayer.prototype.onRemove.call(this);
|
||||
this.animator.stop();
|
||||
this._removeTileLoader();
|
||||
@ -1855,6 +1860,11 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
},
|
||||
|
||||
error: function (callback) {
|
||||
this.options.errorCallback = callback;
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
||||
@ -2138,6 +2148,11 @@ L.CanvasLayer = L.Class.extend({
|
||||
return this;
|
||||
},
|
||||
|
||||
error: function (callback) {
|
||||
this.provider.options.errorCallback = callback;
|
||||
return this;
|
||||
},
|
||||
|
||||
setOpacity: function (opacity) {
|
||||
this.options.opacity = opacity;
|
||||
this._updateOpacity();
|
||||
@ -2493,6 +2508,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
||||
},
|
||||
|
||||
onRemove: function(map) {
|
||||
this.fire('remove');
|
||||
this._removeTileLoader();
|
||||
map.off({
|
||||
'zoomend': this._clearCaches,
|
||||
@ -2533,6 +2549,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
||||
},
|
||||
|
||||
setSQL: function(sql) {
|
||||
if (this.provider.options.named_map) throw new Error("SQL queries on named maps are read-only");
|
||||
if (!this.provider || !this.provider.setSQL) {
|
||||
throw new Error("this provider does not support SQL");
|
||||
}
|
||||
@ -2693,6 +2710,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
||||
* set the cartocss for the current renderer
|
||||
*/
|
||||
setCartoCSS: function(cartocss) {
|
||||
if (this.provider.options.named_map) throw new Error("CartoCSS style on named maps is read-only");
|
||||
if (!this.renderer) throw new Error('renderer is not valid');
|
||||
var shader = new carto.RendererJS().render(cartocss);
|
||||
this.renderer.setShader(shader);
|
||||
@ -3867,6 +3885,7 @@ var Profiler = require('../profiler');
|
||||
var Uint8Array = torque.types.Uint8Array;
|
||||
var Int32Array = torque.types.Int32Array;
|
||||
var Uint32Array = torque.types.Uint32Array;
|
||||
var Uint8ClampedArray = torque.types.Uint8ClampedArray;
|
||||
|
||||
// format('hello, {0}', 'rambo') -> "hello, rambo"
|
||||
function format(str) {
|
||||
@ -3879,7 +3898,7 @@ var Profiler = require('../profiler');
|
||||
return str;
|
||||
}
|
||||
|
||||
var json = function (options) {
|
||||
var windshaft = function (options) {
|
||||
this._ready = false;
|
||||
this._tileQueue = [];
|
||||
this.options = options;
|
||||
@ -3889,6 +3908,13 @@ var Profiler = require('../profiler');
|
||||
this.options.tiler_domain = options.tiler_domain || 'cartodb.com';
|
||||
this.options.tiler_port = options.tiler_port || 80;
|
||||
|
||||
// backwards compatible
|
||||
if (!options.maps_api_template) {
|
||||
this._buildMapsApiTemplate(this.options);
|
||||
} else {
|
||||
this.options.maps_api_template = options.maps_api_template;
|
||||
}
|
||||
|
||||
this.options.coordinates_data_type = this.options.coordinates_data_type || Uint8Array;
|
||||
|
||||
if (this.options.data_aggregation) {
|
||||
@ -3903,7 +3929,7 @@ var Profiler = require('../profiler');
|
||||
}
|
||||
};
|
||||
|
||||
json.prototype = {
|
||||
windshaft.prototype = {
|
||||
|
||||
/**
|
||||
* return the torque tile encoded in an efficient javascript
|
||||
@ -3938,7 +3964,7 @@ var Profiler = require('../profiler');
|
||||
dates = (1 + maxDateSlots) * rows.length;
|
||||
}
|
||||
|
||||
var type = this.options.cumulative ? Uint32Array: Uint8Array;
|
||||
var type = this.options.cumulative ? Uint32Array: Uint8ClampedArray;
|
||||
|
||||
// reserve memory for all the dates
|
||||
var timeIndex = new Int32Array(maxDateSlots + 1); //index-size
|
||||
@ -4202,31 +4228,53 @@ var Profiler = require('../profiler');
|
||||
}
|
||||
},
|
||||
|
||||
_tilerHost: function() {
|
||||
var opts = this.options;
|
||||
var user = (opts.user_name || opts.user);
|
||||
return opts.tiler_protocol +
|
||||
"://" + (user ? user + "." : "") +
|
||||
_buildMapsApiTemplate: function(opts) {
|
||||
var user = opts.user_name || opts.user;
|
||||
opts.maps_api_template = opts.tiler_protocol +
|
||||
"://" + ((user) ? "{user}.":"") +
|
||||
opts.tiler_domain +
|
||||
((opts.tiler_port != "") ? (":" + opts.tiler_port) : "");
|
||||
},
|
||||
|
||||
_tilerHost: function() {
|
||||
var opts = this.options;
|
||||
var user = opts.user_name || opts.user;
|
||||
return opts.maps_api_template.replace('{user}', user);
|
||||
},
|
||||
|
||||
url: function () {
|
||||
var opts = this.options;
|
||||
var protocol = opts.tiler_protocol || 'http';
|
||||
if (!this.options.cdn_url || this.options.no_cdn) {
|
||||
var cdn_host = opts.cdn_url;
|
||||
var has_empty_cdn = !cdn_host || (cdn_host && (!cdn_host.http && !cdn_host.https));
|
||||
|
||||
if (opts.no_cdn || has_empty_cdn) {
|
||||
return this._tilerHost();
|
||||
}
|
||||
var h = protocol + "://"
|
||||
if (protocol === 'http') {
|
||||
} else {
|
||||
var protocol = this.isHttps() ? 'https': 'http';
|
||||
var h = protocol + "://";
|
||||
if (!this.isHttps()) {
|
||||
h += "{s}.";
|
||||
}
|
||||
var cdn_host = opts.cdn_url;
|
||||
if(!cdn_host.http && !cdn_host.https) {
|
||||
throw new Error("cdn_host should contain http and/or https entries");
|
||||
var cdn_url = cdn_host[protocol];
|
||||
// build default template url if the cdn url is not templatized
|
||||
// this is for backwards compatiblity, ideally we should use the url
|
||||
// that tiler sends to us right away
|
||||
if (!this._isUserTemplateUrl(cdn_url)) {
|
||||
cdn_url = cdn_url + "/{user}";
|
||||
}
|
||||
h += cdn_host[protocol] + "/" + (opts.user_name || opts.user);
|
||||
var user = opts.user_name || opts.user;
|
||||
h += cdn_url.replace('{user}', user)
|
||||
return h;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
_isUserTemplateUrl: function(t) {
|
||||
return t && t.indexOf('{user}') !== -1;
|
||||
},
|
||||
|
||||
isHttps: function() {
|
||||
return this.options.maps_api_template.indexOf('https') === 0;
|
||||
},
|
||||
|
||||
_generateCartoCSS: function() {
|
||||
@ -4293,6 +4341,10 @@ var Profiler = require('../profiler');
|
||||
torque.net.jsonp(url, function (data) {
|
||||
map_instance_time.end();
|
||||
if (data) {
|
||||
if (data.errors){
|
||||
self.options.errorCallback && self.options.errorCallback(data.errors);
|
||||
return;
|
||||
}
|
||||
var torque_key = Object.keys(data.metadata.torque)[0]
|
||||
var opt = data.metadata.torque[torque_key];
|
||||
for(var k in opt) {
|
||||
@ -4314,7 +4366,7 @@ var Profiler = require('../profiler');
|
||||
|
||||
};
|
||||
|
||||
module.exports = json;
|
||||
module.exports = windshaft;
|
||||
|
||||
},{"../":10,"../profiler":17}],22:[function(require,module,exports){
|
||||
var TAU = Math.PI*2;
|
||||
@ -13922,11 +13974,9 @@ module.exports={
|
||||
},
|
||||
"homepage": "https://github.com/cartodb/carto",
|
||||
"_id": "carto@0.15.1-cdb1",
|
||||
"dist": {
|
||||
"shasum": "444d4ad0b3a83d0188ffc5d5c486b722aa5e6556"
|
||||
},
|
||||
"_from": "https://github.com/CartoDB/carto/archive/master.tar.gz",
|
||||
"_resolved": "https://github.com/CartoDB/carto/archive/master.tar.gz"
|
||||
"_shasum": "62534c2975cbee073f10c6c14a0c7e889c9469e7",
|
||||
"_resolved": "https://github.com/CartoDB/carto/archive/master.tar.gz",
|
||||
"_from": "https://github.com/CartoDB/carto/archive/master.tar.gz"
|
||||
}
|
||||
|
||||
},{}]},{},[10])(10)
|
||||
|
6
dist/torque.js
vendored
6
dist/torque.js
vendored
File diff suppressed because one or more lines are too long
88
dist/torque.uncompressed.js
vendored
88
dist/torque.uncompressed.js
vendored
@ -669,6 +669,7 @@ module.exports.TorqueLayer = TorqueLayer;
|
||||
// types
|
||||
var types = {
|
||||
Uint8Array: typeof(global['Uint8Array']) !== 'undefined' ? global.Uint8Array : Array,
|
||||
Uint8ClampedArray: typeof(global['Uint8ClampedArray']) !== 'undefined' ? global.Uint8ClampedArray: Array,
|
||||
Uint32Array: typeof(global['Uint32Array']) !== 'undefined' ? global.Uint32Array : Array,
|
||||
Int16Array: typeof(global['Int16Array']) !== 'undefined' ? global.Int16Array : Array,
|
||||
Int32Array: typeof(global['Int32Array']) !== 'undefined' ? global.Int32Array: Array
|
||||
@ -1613,6 +1614,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
||||
|
||||
this.provider = new this.providers[this.options.provider](this.options);
|
||||
this.renderer = new this.renderers[this.options.renderer](this.getCanvas(), this.options);
|
||||
this.renderer.options.errorCallback = this.options.errorCallback;
|
||||
|
||||
// this listener should be before tile loader
|
||||
this._cacheListener = google.maps.event.addListener(this.options.map, 'zoom_changed', function() {
|
||||
@ -1643,6 +1645,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
||||
},
|
||||
|
||||
setSQL: function(sql) {
|
||||
if (this.provider.options.named_map) throw new Error("SQL queries on named maps are read-only");
|
||||
if (!this.provider || !this.provider.setSQL) {
|
||||
throw new Error("this provider does not support SQL");
|
||||
}
|
||||
@ -1787,6 +1790,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
||||
* set the cartocss for the current renderer
|
||||
*/
|
||||
setCartoCSS: function(cartocss) {
|
||||
if (this.provider.options.named_map) throw new Error("CartoCSS style on named maps is read-only");
|
||||
var shader = new carto.RendererJS().render(cartocss);
|
||||
this.shader = shader;
|
||||
if (this.renderer) {
|
||||
@ -1815,6 +1819,7 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
||||
},
|
||||
|
||||
onRemove: function() {
|
||||
this.fire('remove');
|
||||
CanvasLayer.prototype.onRemove.call(this);
|
||||
this.animator.stop();
|
||||
this._removeTileLoader();
|
||||
@ -1855,6 +1860,11 @@ GMapsTorqueLayer.prototype = torque.extend({},
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
},
|
||||
|
||||
error: function (callback) {
|
||||
this.options.errorCallback = callback;
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
||||
@ -2138,6 +2148,11 @@ L.CanvasLayer = L.Class.extend({
|
||||
return this;
|
||||
},
|
||||
|
||||
error: function (callback) {
|
||||
this.provider.options.errorCallback = callback;
|
||||
return this;
|
||||
},
|
||||
|
||||
setOpacity: function (opacity) {
|
||||
this.options.opacity = opacity;
|
||||
this._updateOpacity();
|
||||
@ -2493,6 +2508,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
||||
},
|
||||
|
||||
onRemove: function(map) {
|
||||
this.fire('remove');
|
||||
this._removeTileLoader();
|
||||
map.off({
|
||||
'zoomend': this._clearCaches,
|
||||
@ -2533,6 +2549,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
||||
},
|
||||
|
||||
setSQL: function(sql) {
|
||||
if (this.provider.options.named_map) throw new Error("SQL queries on named maps are read-only");
|
||||
if (!this.provider || !this.provider.setSQL) {
|
||||
throw new Error("this provider does not support SQL");
|
||||
}
|
||||
@ -2693,6 +2710,7 @@ L.TorqueLayer = L.CanvasLayer.extend({
|
||||
* set the cartocss for the current renderer
|
||||
*/
|
||||
setCartoCSS: function(cartocss) {
|
||||
if (this.provider.options.named_map) throw new Error("CartoCSS style on named maps is read-only");
|
||||
if (!this.renderer) throw new Error('renderer is not valid');
|
||||
var shader = new carto.RendererJS().render(cartocss);
|
||||
this.renderer.setShader(shader);
|
||||
@ -3867,6 +3885,7 @@ var Profiler = require('../profiler');
|
||||
var Uint8Array = torque.types.Uint8Array;
|
||||
var Int32Array = torque.types.Int32Array;
|
||||
var Uint32Array = torque.types.Uint32Array;
|
||||
var Uint8ClampedArray = torque.types.Uint8ClampedArray;
|
||||
|
||||
// format('hello, {0}', 'rambo') -> "hello, rambo"
|
||||
function format(str) {
|
||||
@ -3879,7 +3898,7 @@ var Profiler = require('../profiler');
|
||||
return str;
|
||||
}
|
||||
|
||||
var json = function (options) {
|
||||
var windshaft = function (options) {
|
||||
this._ready = false;
|
||||
this._tileQueue = [];
|
||||
this.options = options;
|
||||
@ -3889,6 +3908,13 @@ var Profiler = require('../profiler');
|
||||
this.options.tiler_domain = options.tiler_domain || 'cartodb.com';
|
||||
this.options.tiler_port = options.tiler_port || 80;
|
||||
|
||||
// backwards compatible
|
||||
if (!options.maps_api_template) {
|
||||
this._buildMapsApiTemplate(this.options);
|
||||
} else {
|
||||
this.options.maps_api_template = options.maps_api_template;
|
||||
}
|
||||
|
||||
this.options.coordinates_data_type = this.options.coordinates_data_type || Uint8Array;
|
||||
|
||||
if (this.options.data_aggregation) {
|
||||
@ -3903,7 +3929,7 @@ var Profiler = require('../profiler');
|
||||
}
|
||||
};
|
||||
|
||||
json.prototype = {
|
||||
windshaft.prototype = {
|
||||
|
||||
/**
|
||||
* return the torque tile encoded in an efficient javascript
|
||||
@ -3938,7 +3964,7 @@ var Profiler = require('../profiler');
|
||||
dates = (1 + maxDateSlots) * rows.length;
|
||||
}
|
||||
|
||||
var type = this.options.cumulative ? Uint32Array: Uint8Array;
|
||||
var type = this.options.cumulative ? Uint32Array: Uint8ClampedArray;
|
||||
|
||||
// reserve memory for all the dates
|
||||
var timeIndex = new Int32Array(maxDateSlots + 1); //index-size
|
||||
@ -4202,31 +4228,53 @@ var Profiler = require('../profiler');
|
||||
}
|
||||
},
|
||||
|
||||
_tilerHost: function() {
|
||||
var opts = this.options;
|
||||
var user = (opts.user_name || opts.user);
|
||||
return opts.tiler_protocol +
|
||||
"://" + (user ? user + "." : "") +
|
||||
_buildMapsApiTemplate: function(opts) {
|
||||
var user = opts.user_name || opts.user;
|
||||
opts.maps_api_template = opts.tiler_protocol +
|
||||
"://" + ((user) ? "{user}.":"") +
|
||||
opts.tiler_domain +
|
||||
((opts.tiler_port != "") ? (":" + opts.tiler_port) : "");
|
||||
},
|
||||
|
||||
_tilerHost: function() {
|
||||
var opts = this.options;
|
||||
var user = opts.user_name || opts.user;
|
||||
return opts.maps_api_template.replace('{user}', user);
|
||||
},
|
||||
|
||||
url: function () {
|
||||
var opts = this.options;
|
||||
var protocol = opts.tiler_protocol || 'http';
|
||||
if (!this.options.cdn_url || this.options.no_cdn) {
|
||||
var cdn_host = opts.cdn_url;
|
||||
var has_empty_cdn = !cdn_host || (cdn_host && (!cdn_host.http && !cdn_host.https));
|
||||
|
||||
if (opts.no_cdn || has_empty_cdn) {
|
||||
return this._tilerHost();
|
||||
}
|
||||
var h = protocol + "://"
|
||||
if (protocol === 'http') {
|
||||
} else {
|
||||
var protocol = this.isHttps() ? 'https': 'http';
|
||||
var h = protocol + "://";
|
||||
if (!this.isHttps()) {
|
||||
h += "{s}.";
|
||||
}
|
||||
var cdn_host = opts.cdn_url;
|
||||
if(!cdn_host.http && !cdn_host.https) {
|
||||
throw new Error("cdn_host should contain http and/or https entries");
|
||||
var cdn_url = cdn_host[protocol];
|
||||
// build default template url if the cdn url is not templatized
|
||||
// this is for backwards compatiblity, ideally we should use the url
|
||||
// that tiler sends to us right away
|
||||
if (!this._isUserTemplateUrl(cdn_url)) {
|
||||
cdn_url = cdn_url + "/{user}";
|
||||
}
|
||||
h += cdn_host[protocol] + "/" + (opts.user_name || opts.user);
|
||||
var user = opts.user_name || opts.user;
|
||||
h += cdn_url.replace('{user}', user)
|
||||
return h;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
_isUserTemplateUrl: function(t) {
|
||||
return t && t.indexOf('{user}') !== -1;
|
||||
},
|
||||
|
||||
isHttps: function() {
|
||||
return this.options.maps_api_template.indexOf('https') === 0;
|
||||
},
|
||||
|
||||
_generateCartoCSS: function() {
|
||||
@ -4293,6 +4341,10 @@ var Profiler = require('../profiler');
|
||||
torque.net.jsonp(url, function (data) {
|
||||
map_instance_time.end();
|
||||
if (data) {
|
||||
if (data.errors){
|
||||
self.options.errorCallback && self.options.errorCallback(data.errors);
|
||||
return;
|
||||
}
|
||||
var torque_key = Object.keys(data.metadata.torque)[0]
|
||||
var opt = data.metadata.torque[torque_key];
|
||||
for(var k in opt) {
|
||||
@ -4314,7 +4366,7 @@ var Profiler = require('../profiler');
|
||||
|
||||
};
|
||||
|
||||
module.exports = json;
|
||||
module.exports = windshaft;
|
||||
|
||||
},{"../":10,"../profiler":17}],22:[function(require,module,exports){
|
||||
var TAU = Math.PI*2;
|
||||
|
@ -76,7 +76,7 @@
|
||||
}
|
||||
|
||||
var flags = {
|
||||
sprites_to_images: userAgent().indexOf('Safari') === -1
|
||||
sprites_to_images: userAgent().indexOf('Safari') === -1 && userAgent().indexOf('Firefox') === -1
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -2,6 +2,7 @@
|
||||
// min value to render a line.
|
||||
// it does not make sense to render a line of a width is not even visible
|
||||
var LINEWIDTH_MIN_VALUE = 0.05;
|
||||
var MAX_SPRITE_RADIUS = 255;
|
||||
|
||||
function renderPoint(ctx, st) {
|
||||
ctx.fillStyle = st['marker-fill'];
|
||||
@ -78,12 +79,13 @@
|
||||
if (st['marker-fill-opacity'] !== undefined || st['marker-opacity'] !== undefined) {
|
||||
ctx.globalAlpha = st['marker-fill-opacity'] || st['marker-opacity'];
|
||||
}
|
||||
ctx.drawImage(img, 0, 0, img.width, img.height);
|
||||
ctx.drawImage(img, 0, 0, Math.min(img.width, MAX_SPRITE_RADIUS), Math.min(img.height, MAX_SPRITE_RADIUS));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
renderPoint: renderPoint,
|
||||
renderSprite: renderSprite,
|
||||
renderRectangle: renderRectangle
|
||||
renderRectangle: renderRectangle,
|
||||
MAX_SPRITE_RADIUS: MAX_SPRITE_RADIUS
|
||||
};
|
||||
|
@ -132,17 +132,27 @@ var ballRenderer = require('./ball.js');
|
||||
// take into account the exterior ring to calculate the size
|
||||
var canvasSize = (st['marker-line-width'] || 0) + pointSize*2;
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
var markerFile = st["marker-file"] || st["point-file"];
|
||||
var qualifiedUrl = markerFile && this._qualifyURL(markerFile);
|
||||
|
||||
if (qualifiedUrl && this._iconsToLoad <= 0 && this._icons[qualifiedUrl]) {
|
||||
var img = this._icons[qualifiedUrl];
|
||||
|
||||
var dWidth = Math.min(st['marker-width'] * 2 || img.width, cartocss.MAX_SPRITE_RADIUS * 2);
|
||||
var dHeight = Math.min((st['marker-height'] || dWidth) * (img.width / img.height), cartocss.MAX_SPRITE_RADIUS * 2);
|
||||
|
||||
canvas.width = ctx.width = dWidth;
|
||||
canvas.height = ctx.height = dHeight;
|
||||
|
||||
ctx.scale(dWidth/img.width, dHeight/img.height);
|
||||
|
||||
cartocss.renderSprite(ctx, img, st);
|
||||
} else {
|
||||
// take into account the exterior ring to calculate the size
|
||||
var canvasSize = (st['marker-line-width'] || 0) + pointSize*2;
|
||||
var w = ctx.width = canvas.width = ctx.height = canvas.height = Math.ceil(canvasSize);
|
||||
ctx.translate(w/2, w/2);
|
||||
|
||||
var img_name = this._qualifyURL(st["marker-file"] || st["point-file"]);
|
||||
if (img_name && this._icons.itemsToLoad <= 0) {
|
||||
var img = this._icons[img_name];
|
||||
img.w = st['marker-width'] || img.width;
|
||||
img.h = st['marker-width'] || st['marker-height'];
|
||||
cartocss.renderSprite(ctx, img, st);
|
||||
}
|
||||
else {
|
||||
var mt = st['marker-type'];
|
||||
if (mt && mt === 'rectangle') {
|
||||
cartocss.renderRectangle(ctx, st);
|
||||
|
Loading…
Reference in New Issue
Block a user