Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 13:56
What would you like to do?
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css styles/vendor.css -->
<!-- bower:css -->
<!-- endbower -->
<!-- endbuild -->
<!-- build:css(.tmp) styles/main.css -->
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
<script src="bower_components/modernizr/modernizr.js"></script>
<!--[if lt IE 10]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="">upgrade your browser</a> to improve your experience.</p>
<div class="container">
<div class="header">
<ul class="nav nav-pills pull-right">
<li class="active"><a href="#">東京都 23区</a></li>
<li><a href="#">東京都 島しょ部除く</a></li>
<li><a href="#">東京都 全域</a></li>
<h3 class="text-muted">東京ポリゴン</h3>
<div class="row">
<span id="cityname">名称</span>
<span id="citycode" class="small">JISコード</span>
<div class="row">
<div id="main"></div>
<div class="footer">
<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/d3/d3.min.js"></script>
<!-- endbower -->
<!-- endbuild -->
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
<!-- build:js scripts/plugins.js -->
<script src="bower_components/sass-bootstrap/js/affix.js"></script>
<script src="bower_components/sass-bootstrap/js/alert.js"></script>
<script src="bower_components/sass-bootstrap/js/dropdown.js"></script>
<script src="bower_components/sass-bootstrap/js/tooltip.js"></script>
<script src="bower_components/sass-bootstrap/js/modal.js"></script>
<script src="bower_components/sass-bootstrap/js/transition.js"></script>
<script src="bower_components/sass-bootstrap/js/button.js"></script>
<script src="bower_components/sass-bootstrap/js/popover.js"></script>
<script src="bower_components/sass-bootstrap/js/carousel.js"></script>
<script src="bower_components/sass-bootstrap/js/scrollspy.js"></script>
<script src="bower_components/sass-bootstrap/js/collapse.js"></script>
<script src="bower_components/sass-bootstrap/js/tab.js"></script>
<!-- endbuild -->
<!-- build:js({app,.tmp}) scripts/main.js -->
<script src="scripts/main.js"></script>
<!-- endbuild -->
/*global d3*/
'use strict';
var width = 960,
height = 520;
var files = [
{name: 'tokyo23.geojson', scale: 50000},
{name: 'tokyo-honsyu.geojson', scale: 64000},
{name: 'tokyo.geojson', scale: 8000}
var g ='#main').append('svg')
.attr('width', width)
.attr('height', height)
function renderGeoJSON(f) {
d3.json(, function(err, collection) {
if (err) {
var projection = d3.geo.mercator()
.translate([width / 2, height / 2]);
var path = d3.geo.path().projection(projection);
.attr('d', path)
.attr('class', function(d) {
return 'area area' + ( ? 'City' : '23');
.attr('data-cityname', function(d) {
return ? : '' + ? : '';
.attr('data-citycode', function(d) {
.on('click', function() {
var self =;'#cityname').text(self.attr('data-cityname'));'#citycode').text(self.attr('data-citycode'));
renderGeoJSON(files[0]);'ul.nav li:nth-child(1) a')
.on('click', function() {
$('ul.nav li').removeClass('active');
});'ul.nav li:nth-child(2) a')
.on('click', function() {
$('ul.nav li').removeClass('active');
});'ul.nav li:nth-child(3) a')
.on('click', function() {
$('ul.nav li').removeClass('active');
$icon-font-path: "/bower_components/sass-bootstrap/fonts/";
@import 'sass-bootstrap/lib/bootstrap';
#main {
border: solid 2px gray;
.area23 { fill: #ddc; }
.areaCity { fill: #cdc; }
.areaIsle { fill: #cdd; }
.area { stroke: #000000; }
.area:hover { fill: #00ffff; }
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment