Skip to main content

Questions tagged [carto-js]

CARTO.js is a JavaScript library that interacts with different CARTO APIs. It is part of the CARTO Engine ecosystem.

Filter by
Sorted by
Tagged with
1 vote
1 answer
137 views

Carto JS no sublayer event response

I'm trying to create a custom infowindow based on cartojs sublayer. I've tried many things, but through testing I think the issue is that the event is not being registered/recognized on any of my ...
1 vote
1 answer
145 views

TypeError: layer should be provided

I am updating an old demo that used the first versions of Cartodb so that is runs with the latest version of cartodb.js. I am trying to overlay a set of points on the base map and getting the ...
1 vote
1 answer
894 views

Setting zIndex of CartoDB.js layer on top of Google Map's GroundOverlay?

I am trying to combine the Google Maps API Ground Overlay example with CartoDB.js example using Google Maps. It appears both APIs are displaying their layers correctly. However, the ground overlay ...
0 votes
1 answer
806 views

Creating Leaflet layer that can be toggled in layer control from CartoDB viz.json?

How do I create a leaflet layer that can be toggled in the layer control from a cartodb viz.json? I have read that the cartodb.createlayer does not create a leaflet layer. It seems you can add the ...
0 votes
1 answer
262 views

The ordering of layers with CartoDB/Leaflet [closed]

Just want to get a bit of clarity about this query from before: Layer order in CartoDB I have a map with a Basemap and I want to draw points between features based on layer featureclicks, The good ...
0 votes
1 answer
301 views

CartoDB: Adding another view of layer using Layer Actions and Toggle Buttons

I would like to add multiple sublayers of the same table attached to a single layeraction in cartodb js. I written my webpage based on the following cartodb tutorial: http://docs.cartodb.com/tutorials/...
2 votes
1 answer
777 views

How to include data from other tables in the info-window in CartoDB

I have 3 layers(table_1,table_2,table_3) of data. In the info-window, which was created for the second layer. I would like to display one column of data from table_1 . When I used {{table_1.name}}to ...
0 votes
1 answer
304 views

Publishing filters on cartoDB map

I want users to interact with my CartoDB map by interacting with filters. The CartoDB Editor allows to filter data but there doesn't appear to be an option to "expose" the filters to the end-user. Is ...
0 votes
1 answer
416 views

Data from dataview doesn't update after changing the operation

I'm trying to update some dataviews' operation by a select item. The operation has been changed but the data didn't (so it doesn't trigger a 'dataChanged'). I've tried without boundingBoxFiltering but ...
1 vote
1 answer
719 views

Leaflet display only clicked element of a loaded map layer (polyline)

I am creating a web mapping application that will return appropriate routes based upon ST_length query on a cartoDB dataset. So far, the code below successfully maps those routes with individual ...
0 votes
1 answer
429 views

How to use the the Category Widget in the CartoJS v4?

I'm looking into using the Category Widget in a custom Map, using Carto JS v4. I've managed to get the data to show up on my map, and Now I want to have a category Widget, like the one you have Carto ...
-1 votes
1 answer
599 views

Using Carto.js with free account? [closed]

I have a website running with an old CartoDB account and I would like to make some improvements. With the arrival of CARTO BUILDER, I lost the opportunity to share layers and thus be able to use ...
0 votes
1 answer
160 views

replacement for cartodb.SQL({user: 'user'}).execute(sqlquery) in new cartojs

this used to be my code in older carto.js cartodb.SQL({user: 'user'}).execute(sqlquery).done(function (data){ console.log(data); } how to readapt it in newer cartojs 4.0 beta
2 votes
1 answer
357 views

Setting the extent in cartodb to the sublayer bounds

How do you set the extent of a sublayer to fit all of the points? I've been trying to use this bounds function, but it doesn't work: sql.getBounds('select * from table').done(function(bounds) { ...
0 votes
2 answers
585 views

Multi layer interactivity not working with carto.js

I've two sublayers with interaction set as true and the proper columns added in the interactivity method. The featureClick listener is attached to the layer. On the one hand, popups are working on ...
0 votes
1 answer
161 views

Cartodb popup opening at wrong location

i am using carto js to load a map and inbuilt leaflet to load additional points following (see image below) is the error i am getting. i am using this js <script src="http://libs.cartocdn.com/...
0 votes
1 answer
315 views

Understanding private "with link" visualizations in Carto?

We are creating web dashboards for a small number of customers (~5) in which each customer can view private business-related statistics. We want to embed some visualizations inside the dashboards. ...
1 vote
1 answer
1k views

Switching from "layer selector" to buttons to toggle between layers in CartoDB

As of now, we have a map that you can toggle between layers using the "layer selector". We want to instead have buttons on the map that, by clicking on one, you can switch between layers. In our's, ...
0 votes
1 answer
508 views

Carto.js - Change infowindow field on click event

How can I get fields in an infowindow to change when I click on something? For example, if this is my infowindow code: cartodb.vis.Vis.addInfowindow(map, layer.getSubLayer(0), ['abbrev']) How can I ...
0 votes
1 answer
241 views

Changing cartodb.createLayer source

I'm applying a Carto named map layer to an existing Leaflet map similar to: cartodb.createLayer(map,{ type: 'namedmap', user_name: **username**, options: { named_map: { ...
4 votes
2 answers
143 views

Unable to connect POSTGIS Table to CARTO

I am a new Carto Builder (enterprise) User and I am trying to connect a Postgres9.6.4 / PostgiS 2.3.1. table to my datasets. Here is my script that should do the trick but I receive an extra long ...
1 vote
1 answer
228 views

Using Carto API in HTML

I am trying to use CARTO API with my HTML to display a map, code below: <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>...
1 vote
1 answer
202 views

Centre map on marker click in CartoDB

How do I centre my map after clicking on a marker in carto js? I'm using createLayer but not sure where my listener should be applied (i.e. to map object created using Leaflet or within createLayer ...
2 votes
1 answer
133 views

Trouble hosting CARTO data on GitHub

I'm having trouble getting data from a createLayer layer to populate a CARTO map when hosted on GitHub. The map itself draws but the data is missing, although, it works when hosted locally. Also, I am ...
0 votes
1 answer
169 views

Proper use of layer.invalidate() in Carto.js

According to the Carto.js documentation, layer.invalidate(): "Refreshes the data. If the data has been changed in the CARTO server those changes will be displayed. Nothing happens otherwise. Every ...
-1 votes
1 answer
397 views

how cartodb.createLayer function works

i am using cartodb.createLayer() function to prepare my web application. I have tried to pass vizjson url and metadata method both to get my layers from my carto account which has total of 8 layers in ...
2 votes
3 answers
2k views

Is there a way to get a viz.json url from Carto Builder?

Questions for any Carto users/developers here. I am trying to find out a way to a get a viz.json url that can be used as an overlay on a Leaflet map using Carto.js API. However, I can't find it under ...
1 vote
1 answer
80 views

Table join not displaying in createLayer function in cartodb.js

I am trying to build on the cartodb tutorial to develop a map of fibre networks in Africa. The example works fine when my SQL select is very simple i.e. var layerSource = { ...
2 votes
2 answers
498 views

Using Odyssey.js with Cartodb.js?

I'm looking to use Odyssey to create an interactive introduction to various data layers on an interactive web map I've created using CartoDB.js. I'd like to have different data layers turned on / off ...
0 votes
1 answer
758 views

Make markers iteractive to show infowindow on click

I've used in my html file: var layerSource = { user_name: 'username', type: 'cartodb', sublayers: [{ sql: "SELECT * FROM post", ...
2 votes
1 answer
254 views

How to increase height of image header in Infowindow?

The CartoDB Infowindow default image header width is max 400, with height always set to a default, which looks to be about 250 so the image is really wide. Is there a way to set the image to be more ...
0 votes
1 answer
226 views

Carto JS only gets cartodb_id on click

Here's my code: function main() { // create leaflet map and define some properties var map= L.map( "map", { ...
1 vote
1 answer
372 views

Can we hide/show a Torque layer and/or set SQL?

Is it possible to select a Torque layer that is part of a visualization? I am using CreateVis and creating button and layer selector so that the user can choose what appears on the map. However, the ...
2 votes
1 answer
162 views

Disabling Torque autoplay + resetting UI

I’m building a map in CartoDB.js that includes multiple layers including a Torque layer. Because there is other information on the map and a sidebar to read, I don’t want the Torque layer to ...
1 vote
1 answer
39 views

Avoid sending CSS with each search in CartoDB

We’re developing a project with CartoDB and we want to show each element with a custom image. We are doing this setting the sublayer.setCartoCSS() with something like this: cartocss: "#map { (…) } #...
1 vote
1 answer
116 views

Problem updating infowindow

I have a problem with the infowindow of one of my sublayers in a Carto map. First of all I'll show my code. I create the layer options and then I get my sublayer. I set its options and a first version ...
1 vote
0 answers
266 views

How to show a carto map in an ionic 2 app?

Has anyone shown a carto map in an ionic 2 app? When I used ionic 1 there was no problem, because it is angular js and I could add the library in the index.html: <link rel="stylesheet" href="http:/...
1 vote
1 answer
131 views

How to get sublayer infowindow to close in Carto.js

I have a map with 5 different sublayers and am having an issue with the infowindows between sublayers. If I click on a sublayer point to open an infowindow and then click on a different sublayer to ...
-1 votes
1 answer
297 views

Custom Infowindow Image Height in CartoDB

I have a problem in CartoDB Where I want the Infowindow's embedded header image to have a minimum height to allow for off-the-shelf images from a journalist. I've started with this, which allows me ...
-1 votes
1 answer
148 views

Map with polygons evolution over time

I want to put a button on a map with polygons so that you can see an evolution over time. The problem is that clicking on these buttons is not getting any response. It also happens that the provinces ...
2 votes
1 answer
469 views

How to query the data using SQL in the infowindow of CartoDB

I want to use a SQL join to merge data from 2 tables and display it in the info-window. When I give my query Select table_2.hos_name,table_2.revenue from table_1,table_2 where table_1.area_name = ...
2 votes
0 answers
3k views

What are the licensing rules for using cartodb's public REST API with leafletjs

I am currently working on a project which needs some offline mapping. I am using Leaflet.js as my base library. I have also seen that leaflet can be used with the following tile providers: https://...
-1 votes
2 answers
322 views

2 cartodb maps in 1 html page (with cartodb.js and API code)

I need to use 2 cartodb maps on the same html page. I've done many test, but I'm a newbie with javascript and I've not find any way. Below my code: for one map it works, for two it doesn't. <...
2 votes
1 answer
351 views

Centering map with Carto Builder?

In previous versions of Carto it was easy to set the zoom and center-point of a map embed via URL parameters http://<username>.carto.com/viz/<viz_id>/embed_map?zoom=3&center_lat=0&...
1 vote
1 answer
636 views

Carto: Markers being offset or cut-off on polygon & marker map

I am seeing artifacts and markers are getting cut-off on my map. Zooming in and out can also leave an 'imprint' of what the map looked like before - either for a few seconds or until you refresh the ...
0 votes
1 answer
952 views

Toggle between layers in Carto Builder

If you publish a map with multiple layers using Carto Builder, is there a way for viewers of a map to toggle on/off a specific layer? For example, imagine a choropleth map with a map marker overlay. ...
1 vote
1 answer
125 views

MIME type not executable error in CartoDB

I'm having trouble serving a layer using the Cartodb JS API. Essentially, the script is being refused because of MIME type. I notice ?callback=vizjson has been appended to the end of the URL (see ...
1 vote
3 answers
188 views

carto api with javascript using online carto db. Argument of WHERE must be type boolean, not type geometry

I am using cartodb api to fetch the geojson from the cartodb data set using this code var map = L.map('map',{ center: [-35.1393961, 149.8530818], zoom: 13}); var alpha=map.getBounds(); var lat0=...
2 votes
1 answer
2k views

Including chart based on fields in CartoDB infowindow?

I would like to make graphs, pie charts, etc based on fields in my table within my infowindows. Is there a way to accomplish this?
1 vote
1 answer
793 views

CARTO/Leaflet: How to improve map performance?

I'm having problems getting my map to load data consistently quickly and smoothly. The buttons on my map execute sql queries to display data per category and by year. When I click between them, ...