Skip to main content
100%

Labeled points

✓ Published0🌍 Public
Mmbostock
Last edited Feb 8, 2016
Created on Sep 28, 2010

This example displays a Polymaps map of Oakland crime incidents as labeled points. It adds a text label to each GeoJSON point feature by creating an `svg:text` element with `po.svg`, positioning it with the circle’s `transform`, and centering it via `text-anchor` and `dy`. The code styles the circles with a steelblue stroke, and the map layers CloudMade tiles with the crime data from crimespotting.org.

AI-generated description

This example shows how to add text labels to GeoJSON point features in Polymaps. We create a new svg:text element and insert it as a following sibling to the default svg:circle element provided by the GeoJSON layer. The “dy” and “text-anchor” attributes are used to center the text horizontally and vertically.

Implementation Note: This example depends on the circle element’s “transform” attribute. In release 2.2.0, the circle element used the “cx” and “cy” attributes instead. Release 2.3.0 will use the “transform” attribute and is available in my personal fork.

gpl-3.0 Licensed

Similar vizzes