A quick example demonstrating the use of "show" event handlers and reshow, which allows you to restyle GeoJSON features dynamically from an external event. In this example, you can use the jQuery UI slider in the top-left corner to resize the points.
| #!/usr/bin/perl | |
| use strict; | |
| use warnings; | |
| use 5.010; | |
| use CAM::PDF; | |
| use DBI; | |
| use SQL::Abstract; | |
| use List::AllUtils qw(zip); | |
| use Term::ProgressBar 2.00; |
| d3.scale.flexiclass = function(class_alg) { | |
| return d3_scale_flexiclass([], [], class_alg); | |
| }; | |
| function d3_scale_flexiclass(domain, range, class_alg) { | |
| var thresholds; | |
| function rescale() { | |
| var geostats_class = new geostats(domain); | |
| var k = 0, |
| <html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
| <title>Treemap</title> | |
| <script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script> | |
| <script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js"></script> | |
| <script type="text/javascript" src="http://simiantics.net/d3/lib/jquery/jquery.min.js"></script> | |
| <script type="text/javascript" src="http://simiantics.net/d3/lib/jquery-ui/jquery-ui.min.js"></script> | |
| <style type="text/css"> @import url("http://simiantics.net/d3/lib/jquery-ui/jquery-ui.css"); text { font-family: sans-serif; } </style> | |
| <script type="text/javascript" src="http://simiantics.net/treemap_USA.js"></script> |
| { | |
| "cache": { | |
| "name": "Disk", | |
| "path": "stache", | |
| "umask": "0000", | |
| "dirs": "portable" | |
| }, | |
| "layers": { | |
| "eds": { |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script type="text/javascript" src="https://github.com/mbostock/d3/raw/v1.8.4/d3.js"></script> | |
| <script type="text/javascript" src="https://github.com/mbostock/d3/raw/v1.8.4/d3.geo.js"></script> | |
| <script type="text/javascript" src="https://github.com/simplegeo/polymaps/raw/v2.4.0/polymaps.js"></script> | |
| <script type="text/javascript" src="tiler.js"></script> | |
| <style type="text/css"> | |
| @import url("http://github.com/simplegeo/polymaps/raw/v2.4.0/examples/example.css"); |
The default display for GeoJSON points in Polymaps is a 4.5px-radius circle. In this example, I show how to create more traditional pin-style markers for points. This is implemented using a “load” event handler which replaces the default circles with custom path elements.
The marker outline is courtesy of Dmitry Baranovskiy; he has graciously provided over 100 free vector icons to choose from. Of course, there’s no requirement to use vector icons. You could replace the circles with image elements instead, if you prefer raster. But the nice thing about vectors is that we can color them dynamically based on the data, as we do here by generating three categorical color gradients.
| d3.behavior.drag = function() { | |
| var x = 0, | |
| y = 0, | |
| listeners = [], | |
| dragit | |
| function drag() { | |
| var container = this | |
| .on("mousedown", mousedown) |
Implementation of Jarke J. van Wijk and Wim A.A. Nuij's smooth and efficient zooming and panning for Polymaps.
Type a place name in the search box, top right, and hit "Go!" to fly there.
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script type="text/javascript" src="https://github.com/mbostock/d3/raw/v1.8.4/d3.js"></script> | |
| <script type="text/javascript" src="https://github.com/mbostock/d3/raw/v1.8.4/d3.geo.js"></script> | |
| <script type="text/javascript" src="https://github.com/simplegeo/polymaps/raw/v2.4.0/polymaps.js"></script> | |
| <script type="text/javascript" src="tiler.js"></script> | |
| <style type="text/css"> | |
| @import url("http://github.com/simplegeo/polymaps/raw/v2.4.0/examples/example.css"); |