From e590c206013bef0d991fa3e187b161f194323653 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 25 Mar 2015 22:05:10 +0100 Subject: Start with campus map --- js/campus.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 js/campus.js (limited to 'js/campus.js') diff --git a/js/campus.js b/js/campus.js new file mode 100644 index 0000000..941d5bb --- /dev/null +++ b/js/campus.js @@ -0,0 +1,39 @@ +define(['campus-coords', 'd3'], function(coords, d3) { + 'use strict'; + + var imageUrl = 'images/campus.jpg'; + + function initSvg(svg) { + svg + .attr('width', 1280) + .attr('height', 893); + + svg.append('image') + .attr('xlink:href', imageUrl) + .attr('width', 1280) + .attr('height', 893); + + svg.append('g') + .selectAll('polygon') + .data(coords) + .enter() + .append('a') + .attr('xlink:href', function(d) { + return '#/campus/' + d.name; + }) + .append('polygon') + .attr('class', 'building') + .attr('points', function(d) { + return d.coords.join(' '); + }) + .append('title') + .text(function(d) { + return d.name; + }); + } + + return function() { + var svg = d3.select('#campus-map').append('svg'); + initSvg(svg); + }; +}); -- cgit v1.2.1