Created
June 28, 2012 21:39
-
-
Save pere/3014104 to your computer and use it in GitHub Desktop.
new geo bubbles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"type":"FeatureCollection","features":[{"type":"Feature","id":1,"properties":{"name":"Conservatoire Botanique National du Bassin Parisien (CBNBP)","city":"Paris","num_collections":1,"url":null},"geometry":{"type":"Point","coordinates":[2.34,48.86]}},{"type":"Feature","id":2,"properties":{"name":"Service du Patrimoine Naturel","city":"Paris","num_collections":1,"url":null},"geometry":{"type":"Point","coordinates":[2.34,48.86]}},{"type":"Feature","id":3,"properties":{"name":"Mus\u00e9um National d'Histoire Naturelle (MNHN)","city":"Paris","num_collections":8,"url":null},"geometry":{"type":"Point","coordinates":[2.34,48.86]}},{"type":"Feature","id":11,"properties":{"name":"Centre de Ressources Biologiques de l'institut Pasteur (CRBIP)","city":"Paris","num_collections":1,"url":null},"geometry":{"type":"Point","coordinates":[2.34,48.86]}},{"type":"Feature","id":15,"properties":{"name":"Universit\u00e9 Pierre et Marie Curie (UPMC)","city":"Paris","num_collections":1,"url":null},"geometry":{"type":"Point","coordinates":[2.34,48.86]}},{"type":"Feature","id":16,"properties":{"name":"Institut Fran\u00e7ais de Recherche pour l'Exploitation de la Mer (IFREMER)","city":"Paris","num_collections":1,"url":null},"geometry":{"type":"Point","coordinates":[2.34,48.86]}},{"type":"Feature","id":4,"properties":{"name":"Tela Botanica","city":"Montpellier","num_collections":2,"url":null},"geometry":{"type":"Point","coordinates":[3.88,43.61]}},{"type":"Feature","id":14,"properties":{"name":"Mus\u00e9um d'Histoire Naturelle de Nice","city":"Nice","num_collections":1,"url":null},"geometry":{"type":"Point","coordinates":[7.28,43.7]}},{"type":"Feature","id":5,"properties":{"name":"Mus\u00e9e Zoologique de Strasbourg","city":"Strasbourg","num_collections":3,"url":null},"geometry":{"type":"Point","coordinates":[7.74,48.59]}},{"type":"Feature","id":8,"properties":{"name":"Universit\u00e9 de Strasbourg","city":"Strasbourg","num_collections":3,"url":null},"geometry":{"type":"Point","coordinates":[7.74,48.59]}},{"type":"Feature","id":13,"properties":{"name":"Microbial Observatory of the Laboratoire Arago","city":"Banyuls","num_collections":1,"url":null},"geometry":{"type":"Point","coordinates":[3.13,42.48]}},{"type":"Feature","id":6,"properties":{"name":"Mus\u00e9um d'Histoire Naturelle de Bourges","city":"Bourges","num_collections":1,"url":null},"geometry":{"type":"Point","coordinates":[2.39,47.08]}},{"type":"Feature","id":9,"properties":{"name":"Conservatoire Botanique de Franche-Comt\u00e9","city":"Besan\u00e7on","num_collections":1,"url":null},"geometry":{"type":"Point","coordinates":[6.03,47.24]}},{"type":"Feature","id":10,"properties":{"name":"Museum Henri-Lecoq de Clermont-Ferrand","city":"Clermont-Ferrand","num_collections":1,"url":null},"geometry":{"type":"Point","coordinates":[3.08,45.78]}},{"type":"Feature","id":12,"properties":{"name":"Atlas des plantes vasculaires de Lorraine (Floraine)","city":"Villers-les-Nancy","num_collections":1,"url":null},"geometry":{"type":"Point","coordinates":[6.15,48.67]}},{"type":"Feature","id":7,"properties":{"name":"Institut national de la recherche agronomique (INRA)","city":"Lusignan","num_collections":4,"url":null},"geometry":{"type":"Point","coordinates":[0.12,46.44]}},{"type":"Feature","id":17,"properties":{"name":"Centre INRA Poitou-Charentes","city":"Lusignan","num_collections":4,"url":null},"geometry":{"type":"Point","coordinates":[0.12,46.44]}}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> | |
<title>France bubbling</title> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.7.4"></script> | |
<style type="text/css"> | |
svg { | |
width: 900px; | |
height: 500px; | |
border: solid 1px #ccc; | |
background: #eee; | |
} | |
line { | |
stroke: brown; | |
stroke-dasharray: 4,2; | |
} | |
path { | |
fill: #ccc; | |
stroke: #fff; | |
} | |
div { | |
width: 900px; | |
} | |
</style> | |
</head> | |
<body> | |
<h3>Mercator Projection</h3> | |
<script type="text/javascript"> | |
width= 900; | |
height= 500; | |
//focusing france on SVG | |
xy=d3.geo.mercator().translate([453,1872]).scale(11000) | |
path=d3.geo.path().projection(xy); | |
var svg = d3.select("body") | |
.append("svg") | |
.append("g") | |
.attr("id", "polygons"); | |
//svg.append("g").attr("id", "polygons"); | |
//svg.append("g").attr("id", "points") | |
//.append("svg").attr("id", "points") | |
d3.json('regions.json', function(collection) { | |
console.warn(collection.features) | |
svg.select("#polygons") | |
.selectAll("path") | |
.data(collection.features) | |
.enter().append("path") | |
.attr("d", d3.geo.path().projection(xy)); | |
console.info(d3.geo.path().projection(xy)) | |
}); | |
/* | |
d3.json('datapublishers.json', function(data) { | |
var force = d3.layout.force() | |
.charge(-0.9) | |
.nodes(data.features) | |
.size([960, 500]) //without size does not work | |
.size([100, 100]) | |
.start(); | |
var to_bubble=[] | |
filter_by_city =function (city) | |
{ | |
data.features.forEach(function(data) { | |
if (data.properties.city==city) | |
{ | |
to_bubble.push(data) | |
} | |
}) | |
return to_bubble; | |
} | |
var node = d3.select("svg").selectAll("g") | |
.data(data.features) //filter_by_city('Paris') | |
.enter().append("g") | |
.attr("id", function(d){ return d.properties.city;}) | |
node.append("circle") | |
.attr("transform", function(d) { | |
return "translate(" + xy(d.geometry.coordinates) + ")"; }) | |
.attr("id", function(d){ return d.id;}) | |
.attr("class", "node") | |
.attr('fill','blue') | |
.attr('opacity',0.5) | |
.attr('r', function(d) { | |
return d.properties.num_collections*5}) | |
.call(force.drag); | |
force.on("tick", function() { | |
node.attr( | |
"transform", | |
function(d) { return "translate(" + d.x + "," + d.y + ")"; } | |
); | |
}); | |
}); | |
*/ | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment