Skip to content

Instantly share code, notes, and snippets.

@tokumine
Created January 27, 2012 17:57
Show Gist options
  • Save tokumine/1690025 to your computer and use it in GitHub Desktop.
Save tokumine/1690025 to your computer and use it in GitHub Desktop.
carto to use labels in CartoDB maps
Just a quick sketch to explain how to use labels in CartoDB:
http://dl.dropbox.com/u/193220/CartoDB/labels.png
Something like this should work while we sort out exactly how to release this:
#populated_places_points_2{
marker-fill:#0099FF;
marker-line-color:white;
marker-line-width:1;
marker-opacity:0.68;
marker-line-opacity:0.68;
marker-width:20px;
marker-placement:point;
marker-type:ellipse;
marker-allow-overlap:true;
text-face-name: "DejaVu Sans Book";
text-fill:#000;
text-size:9;
text-transform:uppercase;
text-halo-fill:rgba(255,255,255,1);
text-halo-radius:1;
text-line-spacing:1;
text-wrap-width:20;
text-allow-overlap:true;
text-name:"[name]";
}
(secret is text-allow-overlap:true;)
@fpedrera
Copy link

Cool!

https://fpedrera.cartodb.com/tables/airbase_es_v5_stations/embed_map?sql=SELECT%20*%20FROM%20airbase_es_v5_stations

Now it's time to play!

@sromalewski
Copy link

Is there a CSS property to force polygon labels to stay inside the polygon? You can see from this (crudely annotated) screenshot that Assembly District 85 partially surrounds AD 84, but the label for 85 is placed within AD 84 (likely because of the polygon's centroid location). http://dl.dropbox.com/u/20314275/cartoDBlabels_outsidedistrict.PNG

I guess I could create a new centroid layer and ensure that each location is within it's parent polygon. But can I do it on the fly with CSS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment