Giter VIP home page Giter VIP logo

carto.js's Introduction

CARTO.js 4

CARTO.js is a JavaScript library to create custom location intelligence applications that leverage the power of CARTO. It is the library that powers Builder and it is part of the Engine ecosystem.

Getting Started

The best way to get started is to navigate through the CARTO.js documentation site:

  • Guide will give you a good overview of the library.
  • API Reference will help you use a particular class or method.
  • Examples will demo some specific features.
  • Support might answer some of your questions.

Versioning

We use SemVer for versioning.

Please refer to CHANGELOG.md for a list of notables changes for each version of the library.

You can also see the tags on this repository.

Submitting Contributions

You will need to sign a Contributor License Agreement (CLA) before making a submission. Learn more here.

License

This project is licensed under the BSD 3-clause "New" or "Revised" License - see the LICENSE.txt file for details.

Documentation

API Reference

Run npm run docs to build the API reference documentation from jsdoc annotations.

Once the task is done, you can visit docs/public/index.html to check the reference

General documentation

You can read the general documentation that is published at https://carto.com/developers/carto-js/ also in this repo. They are written in Markdown.

Warning: internal links in these documents don't work. They are replaced when the documentation is published in https://carto.com/

Guides

The folder docs/guides contains general information about the CARTO.js library.

  • Quickstart: get started quickly following this tutorial.
  • Upgrade considerations: if you have experience with previous versions of CARTO.js, this is the place to learn the differences between the former library and the newest one.
  • Glossary: terms that appear throughout the documentation.

Examples

In the folder examples/public you can find several folders with example for every feature of CARTO.js.

Reference topics

The document docs/reference/topics.md contains general considerations when working with CARTO.js. It's advisable to read them before diving in the API reference.

Support

The folder docs/support contains several document with support documentation: support options, FAQs, error messages...

Development

Run the tests

npm test

Build the library

npm run build

To watch the files

npm run build:watch

Generate the docs

npm run docs

Release version

npm run bump

To publish a release to the CDN and npm

npm run release

Looking for the previous version?

Previous version cartodb.js v3 it's available here

carto.js's People

Contributors

acanimal avatar alonsogarciapablo avatar amartinj avatar andrewxhill avatar csubira avatar donflopez avatar elenatorro avatar fdansv avatar iagolast avatar iriberri avatar ivanmalagon avatar javierarce avatar javisantana avatar jesus89 avatar jesusbotella avatar johnhackworth avatar matallo avatar michellechandra avatar nobuti avatar oriolbx avatar piensaenpixel avatar ramiroaznar avatar rjimenezda avatar rochoa avatar rubenmoya avatar saleiva avatar victorvelarde avatar viddo avatar xatpy avatar xavijam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

carto.js's Issues

Casos personales

1 En experiencia de usuario:
Cuando compartes un mapa en que no es de la librería.
Si tu resultado final, es compartir un iframe a 100% de ancho, al hacer scroll por la web, si llegas al mapa, hace (zoom-out). (fail no?) rompe la navegación.

Desde librería puedes. cartodb.js puedes con el createVis
es cartodb.createVis(map, tuURL del vizjson) y luego anulando scrollWheelZoom = false. (Pero los usuarios no tan expertos, como yo ☺ ) podrían tener esa opción, MapBox la tiene resuelta, con tan sólo desactivar un botón.

2 En diseño visual:
Cuando compartes un mapa que sea de google-maps, en la parte inferior izquierda se muestran los dos logos de (powered by), pues en iPad 3 retina, el logo de google es “retina” y el de cartodb no, pierde presencia. Google +1 ☺ y cartobd tiene que molar más que google-maps ☺

Gracias. (con todo el corazón) no es trollada ☺

format: 'GeoJSON' is making getBounds unusable

We have a support ticket where a user is getting an error back from sql.getBounds because it is appending the format=GeoJSON parameter. It should not use that parameter (at least not with the current query for getbounds). I asked them if they were using the latest version incase you already caught this.

viz.json compatibility with leaflet-hash

I'm using leaflet-hash on an adaptation of the SQL-switching example from @xavijam. The CartoDB layer fails to load if the page is triggered with a hash other than the original origin. The implementation is otherwise fully-functional, but this is a potential problem for sharing specific locations by URL on this and future projects.

The reported error is:
Uncaught TypeError: undefined is not a function cartodb.js:15 (anonymous function) cartodb.js:15 window.vizjson cartodb.js:15 (anonymous function) viz.json:1

Should I cross-post at leaflet-hash?

review performance on android devices

from mailing list:

I'm using CartoDB for a mobile web tool. Everything is working great, but my maps aren't working well on Android (4.1.2). Even without data, pan and zoom via touch are painfully slow. 

I'm using leaflet and mapbox tiles: https://dnv9my2eseobd.cloudfront.net/v3/cartodb.map-pp0tkn8d/{z}/{x}/{y}.png

You can view the tool here: [m.cyclee.org](http://m.cyclee.org)
Skip register, click the logo. Then click a placemarker. 

Here's a page with everything but jquery and cartodb.js stripped away:
[app.cyclee.org/static/map.html](http://app.cyclee.org/static/map.html)

A Semicolon's epic journey to the SQL API

Semicolons seem not to work at the end of calls to the SQL API, at least when they're constructed within cartodb.js, as in this example - try the download links to see what I mean. It fails with the error:

{"error":["syntax error at or near \";\""]}

If I remove the encoded semicolon at the end: %3B - the download works fine. The query also works fine in the cartodb dashboard with the semicolon at the end.

Any idea what's happening there?

Setting query parameter on load is giving an error if the map in the dashboard doesn't have the same SQL as a stored state

Error is model not found. Skype/IRC me and I can give you more details

    cartodb.createLayer(map, 'http://sanhack.cartodb.com/api/v1/viz/13346/viz.json', {
      query:  'SELECT  \
               cartodb_id,\
               the_geom_webmercator,\
               the_geom,\
               phone,\
               class_size,\
               (SELECT count(*) FROM daily_class_count WHERE phone = pr.phone) as bubble_size \
              FROM {{table_name}} pr',
      tile_style: '#{{table_name}}{\
                marker-fill: #FF5C00;\
                marker-opacity: 0.8;\
                marker-allow-overlap: true;\
                marker-placement: point;\
                marker-type: ellipse;\
                marker-width: 48;\
                marker-line-width: 1;\
                marker-line-color: #FFF;\
                marker-line-opacity: 1;\
                [bubble_size <= 5]{marker-width: 40;}\
                [bubble_size <= 4]{marker-width: 32;}\
                [bubble_size <= 3]{marker-width: 24;}\
                [bubble_size <= 2]{marker-width: 18;}\
                [bubble_size <= 1]{marker-width: 12;}\
              }',
      interactivity: "cartodb_id"
    })

addTo(map) method to keep from baselayer changes breaking code

Right now, on layer creation there is a dependency on

map.addLayer(layer);

or

map.overlayMapTypes.setAt(0, layer);

depending on what mapping lib you are using. It would be very helpful if layers had a method that was smart enough to just detect and use the right adding method. If gmaps, it would also obv keep track of its position.

layer.addTo(map, position='top')

or something similar

Interactivity parameter doesn't show the_geom column

If you try to get the the_geom data on the interactivity it doesn't show anything, but if you do something like query:

'select *, ST_asGeoJSON(the_geom) as geom from {{table_name}},
interactivity: 'cartodb_id, geom'

It works.

CartoDB Tiles punched out

I'm still trying to replicate this consistently, but I'm getting empty tile artifacts when calling to CartoDB via the viz.json using layer.setquery() and layer.setcartocss(). Here's the example page.

And here are some examples of the artifacts at work.

Nothing reported at the JS console, and the mapbox tile layers above and below continue to load as normal. I've observed this on Chrome and IE10, but with no consistent pattern. On chrome it has appeared after a few pans, zooms and layer switches, while on IE it appeared on page load but then went away. I haven't seen it on FF or Safari.

Has this popped up anywhere else?

[bug] update killing featureOver bindings

When you have a featureOver method in you model data, leaflet.js is creating a function that calls both the function passed in the model data and the featureOver from the view. BUT when you update the view, you lose the native one

All the IE-only styles are also present in the main CSS file

The docs recommend doing this:

<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v2/themes/css/cartodb.css" />
<!--[if lte IE 8]>
    <link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v2/themes/css/cartodb.ie.css" />
<![endif]-->

But the main CSS file (served to all browsers) contains the entire IE-specific CSS file at the top. So what's the point in the conditional IE stylesheet?

Also, the docs say you should use special stylesheet URLs if you are using HTTPS... but the URLs you give are exactly the same as the plain HTTP URLs.

createVis currently picks mapping client based on viz.json setting, maybe leaflet fallback?

Right now, if you use the very awesome, createVis method, it only needs the map DIV id. However, it uses your setting in viz.json to pick whether to use GMaps or Leaflet. The problem, is that it will require the user to load the GMaps V3 lib if they have gone with GMaps.

That isn't a huge problem. But now if I write code that uses leaflet, and change it in my account to gmaps, i have broken code until I update my html. It might be nicer to fallback to Leaflet.

The problem here is picking a default Leaflet basemap to fallback to.

cc/ @jatorre for thoughts here

featureOut is called when the cursor moves between tiles

from support forum:
"""
Attached is a video of the problem. If that doesn't go through, here is a
link to the video: https://dl.dropbox.com/u/90187911/featureOut%20Bug.mp4

Here is a bl.ocks that I'm using in the video:
http://bl.ocks.org/mhkeller/5093547

I copied this example and added the console.log('featureOver') and
console.log('featureOut') in the appropriate callbacks:
https://github.com/CartoDB/cartodb.js/blob/develop/examples/leaflet.html

You can se that when you hover over the northwest corner of France at
certain zoom levels, featureOut is called even though you don't leave the
polygon.

"""
cc @mhkeller

Add null check for _d parameter in wax.cartodb.js onUp

_d can be undefined in onUp if the click event contains a negative offset value. This can happen if a click even is triggered manually - e.g. through jQuery's trigger event.

The error occurs in the else if (Math.round(pos.y / tol) === Math.round(_d.y / tol) line below interaction.click(e, _d);

How to replicate:
e.g.
$imgDiv is a jQuery reference to an img element.
$cb is a jQuery reference to an input element of type checkbox that is contained in a custom leaflet control.

$imgDiv.click(function () {
    $cb.trigger('click');
});

A workaround is to fake out the x/y for the click event (as follows).

$imgDiv.click(function () {
    var event = $.Event('click');
    event.clientX = 0;
    event.clientY = 0;
    $cb.trigger(event);
});

Tile Layer order errors

Possibly related to issue #41 - The order of tile layers is getting switched on a tile-by-tile basis. My application is set to render tiles from two sources in the following order:

  1. Bottom layer = Mapbox terrain, no labels
  2. CartoDB layer called from viz.json and thematically switchable via the UI at page right
  3. Top layer = Mapbox labels only

After initial page load, the tiles quickly begin drawing in the wrong order for all but one or two tiles. Specifically, layers 2 and 3 are flipped, so that the labels appear underneath the cartodb layer for most of the tiles on the page.

I have only been able to observe this in Chrome. It seems not to happen in FF, IE or Safari.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.