Skip to content

Instantly share code, notes, and snippets.

@ebrelsford
ebrelsford / PinnedOverlay.js
Created January 5, 2017 21:00
React component that pins overlaid children on top of an element's background image
class PinnedOverlay extends React.Component {
constructor(props) {
super(props);
var image = new Image();
image.src = window.getComputedStyle(this.props.overlaid)['background-image'].replace(/"/g,"").replace(/url\(|\)$/ig, "");
this.imageWidth = image.width;
this.imageHeight = image.height;
this.aspectRatio = this.imageWidth / this.imageHeight;
@ebrelsford
ebrelsford / carto-js-builder.md
Last active May 18, 2017 11:05
Potential issues and workarounds when using Carto.js v3 with maps made with the Builder interface

Potential issues and workarounds when using Carto.js v3 with maps made with the Builder interface

When using the current version (v3 as of March 2017) of Carto.js with maps using Carto's new Builder interface, there are some issues you are likely to run into. Here I run through the common issues and some suggested workarounds.

Analysis and Widgets don't work

This is because Carto.js v3 doesn't understand them. Sorry but there is no easy workaround here. In the case of Analysis you could save it as its own layer and use that layer instead.

Legends don't work

@ebrelsford
ebrelsford / index.html
Created March 28, 2017 14:08
Popups with Carto.js v3
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<!--
Load Carto's code so we can pull in our Carto maps.
-->
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
@ebrelsford
ebrelsford / index.html
Last active March 28, 2017 14:32
Start map with custom SQL with Carto.js v3
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<!--
Load Carto's code so we can pull in our Carto maps.
-->
@ebrelsford
ebrelsford / index.html
Created March 28, 2017 14:43
Adding zoom in and zoom out buttons with Carto.js v3
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<!--
Load Carto's code so we can pull in our Carto maps.
-->
@ebrelsford
ebrelsford / index.html
Created March 28, 2017 15:39
Using legends in Carto.js v3
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<!--
Load Carto's code so we can pull in our Carto maps.
-->
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
@ebrelsford
ebrelsford / index.html
Created March 28, 2017 16:07
Hover popups in Carto.js v3
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<!--
Load Carto's code so we can pull in our Carto maps.
-->
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
@ebrelsford
ebrelsford / index.html
Created March 28, 2017 16:14
Hover popups in Carto.js v3, template in HTML
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<!--
Load Carto's code so we can pull in our Carto maps.
-->
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
@ebrelsford
ebrelsford / index.html
Created March 30, 2017 03:49
Popups with Carto.js v3, template in HTML
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<!--
Load Carto's code so we can pull in our Carto maps.
-->
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
@ebrelsford
ebrelsford / index.html
Last active April 20, 2017 15:47
Popups with Carto.js v3 with embedded content
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<!--
Load Carto's code so we can pull in our Carto maps.
-->