From 69d274a095449c39f7f140034a0ca07b7c108e63 Mon Sep 17 00:00:00 2001 From: Greg Scott Date: Tue, 24 Jun 2014 18:53:25 -0600 Subject: [PATCH 1/8] Ignore _site --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ca35be0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +_site From febdc7ae3c1e1bb30d33cae1079661b04646d2b2 Mon Sep 17 00:00:00 2001 From: Greg Scott Date: Tue, 24 Jun 2014 20:51:54 -0600 Subject: [PATCH 2/8] Generate data.js file that contains geojson --- .gitignore | 1 + _plugins/geojson.rb | 17 ++++++++++++++ index.html | 57 +++++++++++++-------------------------------- 3 files changed, 34 insertions(+), 41 deletions(-) create mode 100644 _plugins/geojson.rb diff --git a/.gitignore b/.gitignore index ca35be0..7d57af4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ _site +js/data.js 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..925da7b 100644 --- a/index.html +++ b/index.html @@ -15,9 +15,8 @@
+ - + diff --git a/js/.gitkeep b/js/.gitkeep deleted file mode 100644 index e69de29..0000000 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); From ea6869aca14814c5613c2dfb59b7bf9e407c8b33 Mon Sep 17 00:00:00 2001 From: Greg Scott Date: Wed, 25 Jun 2014 09:13:28 -0600 Subject: [PATCH 8/8] Only specify devDependencies --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index a932104..9b82fc5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,4 @@ { - "name": "last-mile", - "version": "0.1.0", "devDependencies": { "grunt": "^0.4.5", "grunt-gh-pages": "^0.9.1"