Skip to content

Instantly share code, notes, and snippets.

View jsanz's full-sized avatar
🗺️
Mapping

Jorge Sanz jsanz

🗺️
Mapping
View GitHub Profile
@jsanz
jsanz / index.html
Created June 24, 2015 08:50
Basemap covering google maps
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Ejemplo</title>
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
@jsanz
jsanz / README.md
Last active June 6, 2016 19:38
OSM no es un mapa, es una base de datos
@jsanz
jsanz / README.md
Last active November 16, 2017 16:41
CartoDB.js: create a map from a custom viz.json

On this example I pass a vizjson object that defines a leaflet map with a layer, legend, tooltip and infowindows.

@jsanz
jsanz / README.md
Last active August 29, 2015 14:23
CartoDB.js: Education centers count

Add a layer that shows a bubble map of education centers. The point is calculated using simply the centroid of the grouped features.

SELECT 
  int4(row_number() OVER (ORDER BY pro)) AS cartodb_id,
  ST_Centroid(ST_Union(the_geom_webmercator)) AS the_geom_webmercator,
  count(*) as count,
  pro
FROM registro_centros_es
GROUP BY pro
@jsanz
jsanz / README.md
Last active January 9, 2022 23:57
Analysis example: Voronoi on CartoDB

This example loads a CartoDB layer using a crazy SQL from a small variation of this awesome Stack Overflow response. Note the use of CSS style tags for the CartoCSS to allow easy editing.

The uncompressed (and not perfect!) version of the SQL to draw the Voronoi diagram is:

WITH 
    Sample AS (
      SELECT st_setsrid(st_union(the_geom),0) as geom 
      FROM registro_centros_nz WHERE spanish = 1
    ),
@jsanz
jsanz / README.md
Last active August 2, 2017 21:14
CartoDB.js examples: add sublayers

This example shows how to create a Leaflet map with a basemap and an empty CartoDB.js layer. Once the layer is created a function is attached the event of the layers selector checkboxes so on any state change, the sublayers are removed and recreated according to the user selection.

@jsanz
jsanz / README.md
Last active March 27, 2017 16:13
CartoDB.js examples: several createLayer

On this map we create two CartodB layers, one of them is built with two sublayers. In order to control when they are added to the map, we save the promises objects and use the jQuery.when function to execute the code to add the layers to the map when both promises are executed.

@jsanz
jsanz / README.md
Last active January 21, 2016 08:24
CartoDB.js Examples: analysis

Examples on using CartoDB.js.

Create a new layer based on a custom SQL and CSS

@jsanz
jsanz / README.md
Last active August 29, 2015 14:22
CartoDB.js examples: add layer

Examples on using CartoDB.js.

Adding a VizJSON to a Leaflet Map.

@jsanz
jsanz / README.md
Last active August 29, 2015 14:22
CartoDB.js examples: minimal

Examples on using CartoDB.js.

Minimal example on calling a VizJSON