Paul Greyson | c090d14 | 2013-04-09 16:59:03 -0700 | [diff] [blame^] | 1 | |
| 2 | |
| 3 | |
| 4 | (function () { |
| 5 | |
| 6 | createTopologyView = function (cb) { |
| 7 | var svg = d3.select('#svg-container').append('svg:svg'); |
| 8 | |
| 9 | svg.append("svg:defs").append("svg:marker") |
| 10 | .attr("id", "arrow") |
| 11 | .attr("viewBox", "0 -5 10 10") |
| 12 | .attr("refX", -1) |
| 13 | .attr("markerWidth", 5) |
| 14 | .attr("markerHeight", 5) |
| 15 | .attr("orient", "auto") |
| 16 | .append("svg:path") |
| 17 | .attr("d", "M0,-3L10,0L0,3"); |
| 18 | |
| 19 | topology = svg.append('svg:svg').attr('id', 'viewBox').attr('viewBox', '0 0 1000 1000'). |
| 20 | attr('id', 'viewbox'); |
| 21 | |
| 22 | var map = topology.append("g").attr('id', 'map'); |
| 23 | |
| 24 | var projection = d3.geo.mercator() |
| 25 | .center([82, 45]) |
| 26 | .scale(10000) |
| 27 | .rotate([-180,0]); |
| 28 | |
| 29 | var path = d3.geo.path().projection(projection); |
| 30 | |
| 31 | d3.json('data/world.json', function(error, topology) { |
| 32 | map.selectAll('path') |
| 33 | .data(topojson.object(topology, topology.objects.world).geometries) |
| 34 | .enter() |
| 35 | .append('path') |
| 36 | .attr('d', path) |
| 37 | |
| 38 | cb(); |
| 39 | }); |
| 40 | |
| 41 | |
| 42 | // var map = topology.append('svg:g') |
| 43 | // .attr('transform', 'scale(1.7 1.7)translate(-200, 0)'); |
| 44 | |
| 45 | // d3.xml("assets/map.svg", "image/svg+xml", function(xml) { |
| 46 | // var importedNode = document.importNode(xml.documentElement, true); |
| 47 | // var paths = importedNode.querySelectorAll('path'); |
| 48 | // var i; |
| 49 | // for (i=0; i < paths.length; i+=1) { |
| 50 | // map.append('svg:path') |
| 51 | // .attr('class', 'state') |
| 52 | // .attr('d', d3.select(paths.item(i)).attr('d')) |
| 53 | // } |
| 54 | |
| 55 | // cb(); |
| 56 | // }); |
| 57 | } |
| 58 | |
| 59 | drawTopology = function () { |
| 60 | |
| 61 | } |
| 62 | |
| 63 | })(); |