Requesting alphamarker from local if needed

pull/10984/head
xavijam 8 years ago committed by Javier Torres
parent 63a2d49e41
commit ec3606a1c6

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@ -70,8 +70,14 @@ module ApplicationHelper
module_function :maps_api_template
module_function :sql_api_template, :sql_api_url
def app_assets_base_url
asset_host = Cartodb.get_config(:app_assets, 'asset_host');
(asset_host.present? ? asset_host : '/public') + '/assets/' + JSON::parse(File.read(Rails.root.join('package.json')))['version'] + '/'
end
def frontend_config
config = {
app_assets_base_url: app_assets_base_url,
maps_api_template: maps_api_template,
sql_api_template: sql_api_template,
user_name: CartoDB.extract_subdomain(request),

@ -270,7 +270,7 @@ var mapCreation = function () {
dashboardView.$el.toggleClass('is-dark', m.isEditing());
});
var styleManager = new StyleManager(layerDefinitionsCollection, vis.map);
var styleManager = new StyleManager(layerDefinitionsCollection, vis.map, configModel);
var editFeatureOverlay = new EditFeatureOverlay({
map: vis.map,

@ -2,9 +2,9 @@ var _ = require('underscore');
var camshaftReference = require('../../data/camshaft-reference');
var Utils = require('../../helpers/utils');
var InputColorCategories = require('../../components/form-components/editors/fill/input-color/input-categories/input-color-categories.js');
var S3_ASSET_URL = '//s3.amazonaws.com/com.cartodb.assets.static/';
var CONFIG = {
HEATMAP_IMAGE: 'url(http://s3.amazonaws.com/com.cartodb.assets.static/alphamarker.png)',
GENERIC_STYLE: camshaftReference.getDefaultCartoCSSForType(),
DEFAULT_HEATMAP_COLORS: ['blue', 'cyan', 'lightgreen', 'yellow', 'orange', 'red']
};
@ -305,12 +305,19 @@ var cartocssFactory = {
}
};
var heatmapConversion = function (style, animated) {
var heatmapConversion = function (style, animated, configModel) {
// modify the size
style.fill = _.clone(style.fill);
var ramp = style.fill.color.range;
style.fill.size = style.fill.size || { fixed: 35 };
style.fill.image = CONFIG.HEATMAP_IMAGE;
var alphaMarkerBaseUrl = S3_ASSET_URL;
if (configModel.get('cartodb_com_hosted')) {
alphaMarkerBaseUrl = configModel.get('app_assets_base_url') + '/images/';
}
style.fill.image = 'url(' + alphaMarkerBaseUrl + 'alphamarker.png)';
style.fill.color = {
fixed: style.fill.color.fixed || 'white',
opacity: style.fill.color.opacity
@ -333,8 +340,8 @@ var styleConversion = {
}
},
heatmap: function (style) {
return heatmapConversion(style, false);
heatmap: function (style, configModel) {
return heatmapConversion(style, false, configModel);
}
};
@ -363,7 +370,7 @@ function isCategoryType (styleDef, geometryType) {
}
}
function generateCartoCSS (style, geometryType) {
function generateCartoCSS (style, geometryType, configModel) {
var css = '';
var styleDef = style.properties;
var isAnimatable = isTypeTorque(style.type);
@ -567,7 +574,7 @@ var AggregatedFactory = {
/**
* given a styleDefinition object and the geometry type generates the query wrapper and the
*/
function generateStyle (style, geometryType, mapContext) {
function generateStyle (style, geometryType, mapContext, configModel) {
if (style.type === 'none') {
return {
cartoCSS: CONFIG.GENERIC_STYLE,
@ -586,7 +593,7 @@ function generateStyle (style, geometryType, mapContext) {
var conversion = styleConversion[style.type];
var properties;
if (conversion) {
properties = conversion(style.properties);
properties = conversion(style.properties, configModel);
if (properties) {
style.properties = properties;
}
@ -605,7 +612,7 @@ function generateStyle (style, geometryType, mapContext) {
var layerType = style.type === 'heatmap' || style.type === 'animation' ? 'torque' : 'CartoDB';
return {
cartoCSS: generateCartoCSS(style, geometryType),
cartoCSS: generateCartoCSS(style, geometryType, configModel),
sql: generateSQL(style, geometryType, mapContext),
layerType: layerType
};

@ -4,9 +4,10 @@ var _ = require('underscore');
/**
* this class manages the changes in layerdef styles and generate the proper cartocss and sql
*/
function StyleManager (layerDefinitionsCollection, map) {
function StyleManager (layerDefinitionsCollection, map, configModel) {
this.layerDefinitionsCollection = layerDefinitionsCollection;
this.map = map;
this._configModel = configModel;
this._initBinds();
}
@ -51,9 +52,14 @@ StyleManager.prototype = {
}
var simpleGeometryType = layerDef.getAnalysisDefinitionNodeModel().queryGeometryModel.get('simple_geom') || 'point';
var generated = StyleGenerator.generateStyle(layerDef.styleModel.toJSON(), simpleGeometryType, {
zoom: this.map.get('zoom')
});
var generated = StyleGenerator.generateStyle(
layerDef.styleModel.toJSON(),
simpleGeometryType,
{
zoom: this.map.get('zoom')
},
this._configModel
);
layerDef.set({
cartocss: generated.cartoCSS,

Loading…
Cancel
Save