diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a303a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +_site +js/data.js +node_modules +.grunt diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..89c40d5 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,14 @@ +module.exports = function(grunt) { + + grunt.initConfig({ + 'gh-pages': { + options: { + base: '_site' + }, + src: ['**'] + } + }); + + grunt.loadNpmTasks('grunt-gh-pages'); + +}; \ No newline at end of file diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..0c4c79f --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +exclude: ["geojson", "node_modules", "script", "Gruntfile.js", "package.json"] \ No newline at end of file diff --git a/_plugins/geojson.rb b/_plugins/geojson.rb new file mode 100644 index 0000000..78a61ce --- /dev/null +++ b/_plugins/geojson.rb @@ -0,0 +1,17 @@ +module Geojson + class Generator < Jekyll::Generator + def generate(site) + data = File.join "js", "data.js"; + File.open data, "w" do |file| + file.puts "var data = [" + + Dir.glob('geojson/*.geojson') do |geojson| + json = File.read(geojson) + "," + file.puts json + end + + file.puts "];" + end + end + end +end \ No newline at end of file diff --git a/index.html b/index.html index 0f73ce6..1859cca 100644 --- a/index.html +++ b/index.html @@ -13,69 +13,8 @@
- - + + diff --git a/js/app.js b/js/app.js new file mode 100644 index 0000000..8df2024 --- /dev/null +++ b/js/app.js @@ -0,0 +1,35 @@ +var map = L.mapbox.map('map', 'examples.map-h67hf2ic') + .setView([61.189100,-149.873723], 12); + +var pickColor = (function() { + var colors = ['#AD0101', '#0D7215', '#4E0963', '#0071CA']; + var colorIndex = Math.floor((Math.random() * colors.length) + 1); + + return function() { + colorIndex++; + if (colorIndex >= colors.length) colorIndex = 0; + return colors[colorIndex]; + }; +})(); + +function load() { + // Iterate the geojson objects from the data found in data.js. + $.each(data, function(index, geojson) { + $.each(geojson.features, function(index, value) { + $.extend(geojson.features[index].properties, { + 'stroke': pickColor(), + 'stroke-opacity': 0.5, + 'stroke-width': 5 + }); + }); + + L.mapbox.featureLayer(geojson) + .eachLayer(function(layer) { + if(layer.feature.properties && layer.feature.properties.desc) { + layer.bindPopup(layer.feature.properties.desc); + } + }).addTo(map); + }) +} + +$(load); diff --git a/package.json b/package.json new file mode 100644 index 0000000..9b82fc5 --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "devDependencies": { + "grunt": "^0.4.5", + "grunt-gh-pages": "^0.9.1" + } +} diff --git a/readme.md b/readme.md index 891b4bb..12eee92 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# [View The Map](http://resourcedatainc.github.io/last-mile/) +# [View The Map](http://gregoryjscott.github.io/last-mile/) [![Build Status][build_png]][travis]