Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

6

Geometries in CartoDB are by default stored with two different coordinate reference systems (CRS). the_geom has coordinates in Degree, while the_geom_webmercator has coordinates in units of meter or smaller depending on latitude. Both systems can be used world wide (Web Mercator excluding the pole areas), but both systems are not appropriate to measure ...


6

You could create an Object before layer.on('loaded'... with the legend keys you want to use for this dataset, for example: const LEGEND_KEYS = { LT: 'Least Threatened', VU: 'Vulnerable', CR: 'Critically Endangered', EN: 'Endangered' } And then, when updating the legend: colorLegendList += `<li><span ...


4

Yes, it is possible by using the reverse expression. Using the code from your example, it would be: color: ramp(globalQuantiles($sa_m3_km2, 10), reverse(temps)) You can find more about this expression in our documentation: https://carto.com/developers/carto-vl/reference/#cartoexpressionsreverse And an example from the reference using the JavaScript API: ...


4

Exactly! The 'loaded' event is only fired when the layer is loaded, but the 'updated' event is fired every time the layer is updated. You can take a look at this example: https://carto.com/developers/carto-vl/examples/#example-viewport-summary We recommend using the 'updated' event only if you need the widget information to change, but if it's going to ...


4

As you mention, the tutorial has a mistake. You're not getting the properties from the feature in the loop correctly. The code from the example is: $categoryWidget.categories = viz.variables.cities.value .map(feature => ({ name: feature.name, value: feature.pop_max, })) .sort((a, b) => b.value - a.value); This is wrong. If you take a ...


3

In order to group your data by country and show only one point, I suggest using Create Centroids of Geometries Builder analysis. Here is a tutorial that exmplains how to do it. As far as I understood your requirement, you will need to set your country column as category and avg, sum... of your numerical value as the aggregation operation. UPDATE: If you ...


3

Checking on old CARTO.js GitHub issues, I have found a workaround that could solve your problem: placing the https after the named map definition: cartodb.createLayer(map, { user_name: user, type: 'namedmap', named_map: { name: 'name_whatever', ... } }, { https: true })


3

You can add labels in CARTO.js using CartoCSS text properties in your layer style object. Something like this should work: #layer { polygon-fill: #826DBA; polygon-opacity: 0.9; } #layer::outline { line-width: 1; line-color: #FFFFFF; line-opacity: 0.5; } #layer::labels { text-name: [name]; text-face-name: 'DejaVu Sans Book'; text-size: 10; ...


3

You're probably making no mistake, Kristen. If you copy & paste exactly the last piece of code from that guide (with the whole html code), there is a relative link to style.css, which you have probably not noticed. The link in the code is: <link rel="stylesheet" type="text/css" href="../../style.css"> a file which you are probably missing ...


3

I think the problem here is that you're passing directly the attribute ($yield_ls) to the ramp expression, and the results are sorted by number of occurrences of each category. In order to classify the content you're receiving, you've to use the buckets as follows: color: ramp(buckets($yield_ls, [ "Fractured 0.0 - 0.1 l/s", "Fractured 0.1 - 0.5 l/s"...


3

Are you using the VL Bridge? If so, there is an undocumented method for the category widget's bridge: enableColorMapping. If the viz bridged to your as-category-widget has a color ramp, it will add the color to the categories automatically. Keep in mind that it's undocumented, so it might change in the future without notice. const bridge = new AsBridge....


2

The package is outdated. We moved it to another place. Please add as dependency @carto/carto.js instead of carto.js and substitute it in whatever file it's used in. npm install @carto/carto.js


2

You were almost there. I've created a diff to show you the places where you need to make some adjustments. Code diff with the explanation You didn't have the style for painting the circles. Added to the CSS. Your cartoCSS asked for a ramp on polygon-fill but you were then asking for marker-fill metadata, I guess based on our examples that are based on point ...


2

You need to use the following type of INSERT query; specifying the source and target column for the insert. This way you can exclude cartodb_id (which is an auto incremented primary key): INSERT INTO existing_table (columna, columnb, columnc) SELECT columna, columnb, columnc FROM new_table;" To help you out and save time you can get a comma ...


2

I have never used ST_SymDifference but (correct me if I am wrong) you can achieve the same result with ST_Difference. But before applying any of these functions, you should bear in mind that any SQL query inside BUILDER should select (a unique) cartodb_id, the_geom and the_geom_webmercator. Check this resource to see how you can clip or create donnuts in ...


2

I would suggest to try to make that map using BUILDER and then copy the resulting CartoCSS on your code. You can also learn more about CartoCSS and TurboCARTO on this guide. Regarding legends, have you checked CARTO.js documentation? There's an explicit example on how to work with legends.


2

The data in the demos is probably specifically processed, but it is not difficult find these open datasets from 'the Internet'. For example, they are in Google BigQuery open datasets, and e.g. https://github.com/toddwschneider/nyc-taxi-data has many useful links.


2

You are right. CARTO's Box connector shows a maximum of 200 files. You can check the source code here. There is a couple of fixes requested that could solve this issue: a Chooser/Picker, show the most recent files. Hopefully, one of these will be addressed soon. Disclaimer: I work at CARTO.


2

Assumming the account in your local installatioin is named me, you can try to define your source like this, which I hope works for you: const source = new carto.source.Dataset( 'compact_regions', { user: 'me', apiKey: 'default_public' }, { serverURL: 'http://me.localhost.lan:8181' } ); If the dataset is not public you'll need to provide a ...


2

You would need to remove the target property or set it as `"_blank" if you want to open a new browser tag. This is a basic HTML, that you can use as an example: <div class="CDB-infowindow CDB-infowindow--light js-infowindow"> <div class="CDB-infowindow-close js-close"></div> <div class="CDB-infowindow-container"> ...


2

You need to assign an action to your dropdown object and use setQuery CARTO.js method to change the layer source as explained in this example. const selector = $(".js-dropdown-selector"); // change sql query with dropdown value selector.on('change', function(e) { let value = e.target.value; console.log(value); if (value == 'megacity') { ...


2

You are only attaching a handler for the featureOver event, but not to the featureOut. If you check the example at the end where events are assigned: function setPopupsHover() { populatedPlacesLayer.off('featureClicked'); populatedPlacesLayer.on('featureOver', openPopup); populatedPlacesLayer.on('featureOut', closePopup); } I also recommend ...


2

The most likely reason is that your widgets are pointing only to the animated layer and its source is independent from the other layers. What you should do if several layers share the same data source is: Create one layer from your data source. In a new map this will be typically the layer A. Drag and drop the source node in that layer A. It's the ...


2

CARTO's Create Travel or Distance Buffers tutorial provides a guide which describes how to apply a buffer as follows: Import the template .carto file packaged from “Download resources” of this guide and create the map. Builder opens with TRI point data as the first map layer, and Census Tract polygons as the second map layer. From the TRI map layer,...


2

You have the correct idea that CartoCSS is something that would assist in this effort of yours. I believe the color ramp will generally work with about 7 or so colors before it lumps everything else in the "Other" category. I would suggest referencing Tips & Tricks - Geospatial Analysis SELECT cartodb_id, the_geom, the_geom_webmercator, ...


2

You were on the right track. In order to style all your categories using CARTO Builder, you need to switch from values to CartoCSS as shown in the following gif: Secondly, you need to update the code using basic CartoCSS conditionals. Notice that you would need to know the category names and colors in advance. You can use a code like this one. #layer { ...


2

To create different individual drive time buffers you can't use BUILDER, as it's not parametrized by a field. Instead, you need to use SQL directly to UPDATE your dataset with the geometries. So if your field for the commute time is commute_time then your query would look like the following queries. Mind that I'm putting the points as latitude/longitude to ...


2

There is no public API to perform that task, even it's supported (with proper warning notice) by CARTO Python SDK, search for the Update the properties of a dataset example. In your case you are looking for the dataset.locked property.


2

There is a non documented property for this. In the histogram is called noDataHeaderMessage https://github.com/CartoDB/airship/blob/master/packages/components/src/components/as-histogram-widget/as-histogram-widget.tsx#L156


2

It's not possible to use both carto.js and CARTO VL in the same HTML file using the cdn, because both use the same "carto" namespace. That's the reason why when you comment one of them, you're using the other. If you add both scripts, the "carto" variable will make reference to the last script you've added. If you want to develop an application with both ...


Only top voted, non community-wiki answers of a minimum length are eligible