diff --git a/_includes/jekyll_mapping b/_includes/jekyll_mapping
deleted file mode 100644
index bc0a4a2..0000000
--- a/_includes/jekyll_mapping
+++ /dev/null
@@ -1,8 +0,0 @@
-{% if site.mapping.provider and page.mapping %}
- {% case site.mapping.provider %}
- {% when "google_js" %}
- {% include jekyll_mapping_providers/google_js %}
- {% when "openstreetmap" %}
- {% include jekyll_mapping_providers/openstreetmap %}
- {% endcase %}
-{% endif %}
\ No newline at end of file
diff --git a/_includes/jekyll_mapping.html b/_includes/jekyll_mapping.html
new file mode 100644
index 0000000..75ebfb2
--- /dev/null
+++ b/_includes/jekyll_mapping.html
@@ -0,0 +1,12 @@
+{% if site.mapping.provider %}
+ {% case site.mapping.provider %}
+ {% when "google_js" %}
+ <script>
+ var jekyllMappingAPIKey = '{{ site.mapping.api_key }}';
+ </script>
+ <script src="/javascripts/gmaps.js"></script>
+ {% when "openstreetmap" %}
+ <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
+ <script src="/javascripts/openstreetmaps.js"></script>
+ {% endcase %}
+{% endif %}
diff --git a/_includes/jekyll_mapping_providers/google_js b/_includes/jekyll_mapping_providers/google_js
deleted file mode 100644
index c45efc0..0000000
--- a/_includes/jekyll_mapping_providers/google_js
+++ /dev/null
@@ -1,67 +0,0 @@
-<script type="text/javascript">
-var jekyllMapping = (function () {
- 'use strict';
- var settings = {% yaml_to_json mapping %};
- return {
- mappingInitialize: function () {
- var options = {
- zoom: settings.zoom,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- }, map, mainMarker;
-
- if (typeof(settings.latitude) !== 'undefined' && typeof(settings.longitude) !== 'undefined') {
- options.center = new google.maps.LatLng(settings.latitude, settings.longitude);
-
- map = new google.maps.Map(document.getElementById("jekyll-mapping"), options);
-
- mainMarker = new google.maps.Marker({
- position: options.center,
- map: map,
- title: "{{ page.title }}"
- });
- } else {
- options.center = new google.maps.LatLng(0, 0);
- map = new google.maps.Map(document.getElementById("jekyll-mapping"), options);
- }
-
- if (settings.locations instanceof Array) {
- var bounds = new google.maps.LatLngBounds(), markers = [], s, l, m;
- while (settings.locations.length > 0) {
- s = settings.locations.pop();
- l = new google.maps.LatLng(s.latitude, s.longitude);
- m = new google.maps.Marker({
- position: l,
- map: map,
- title: s.title
- });
- markers.push(m);
- bounds.extend(l);
- }
- map.fitBounds(bounds);
- }
-
- if (settings.kml) {
- var mainLayer = new google.maps.KmlLayer(settings.kml);
- mainLayer.setMap(map);
- }
-
- if (settings.layers) {
- var layers = [];
- while (settings.layers.length > 0){
- var m = new google.maps.KmlLayer(settings.layers.pop());
- layers.push(m);
- m.setMap(map);
- }
- }
- },
- loadScript: function () {
- var script = document.createElement("script");
- script.type = "text/javascript";
- script.src = "http://maps.googleapis.com/maps/api/js?key={{ site.mapping.api_key}}&sensor=false&callback=jekyllMapping.mappingInitialize";
- document.body.appendChild(script);
- }
- };
-}());
-
-window.onload = jekyllMapping.loadScript();
-</script>
\ No newline at end of file
diff --git a/_includes/jekyll_mapping_providers/openstreetmap b/_includes/jekyll_mapping_providers/openstreetmap
deleted file mode 100644
index 4080dfe..0000000
--- a/_includes/jekyll_mapping_providers/openstreetmap
+++ /dev/null
@@ -1,51 +0,0 @@
-<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
-<script type="text/javascript">
-var jekyllMapping = (function () {
- 'use strict';
- var settings = {% yaml_to_json mapping %};
- return {
- mappingInitialize: function() {
- var map, markers, center;
- markers = new OpenLayers.Layer.Markers("Markers")
- map = new OpenLayers.Map("jekyll-mapping");
- map.addLayer(new OpenLayers.Layer.OSM());
- map.addLayer(markers);
- if (typeof(settings.latitude) !== 'undefined' && typeof(settings.longitude) !== 'undefined') {
- center = new OpenLayers.LonLat(settings.longitude, settings.latitude).transform( new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
- map.setCenter(center, settings.zoom);
- markers.addMarker(new OpenLayers.Marker(center));
- }
-
- if (settings.locations instanceof Array) {
- var s, l, m, bounds = new OpenLayers.Bounds();
- while (settings.locations.length > 0) {
- s = settings.locations.pop();
- l = new OpenLayers.LonLat(s.longitude, s.latitude).transform( new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
- markers.addMarker(new OpenLayers.Marker(l))
- bounds.extend(l);
- }
- map.zoomToExtent(bounds)
- }
-
- if (settings.layers) {
- while (settings.layers.length > 0){
- var m = new OpenLayers.Layer.Vector("KML", {
- strategies: [new OpenLayers.Strategy.Fixed()],
- protocol: new OpenLayers.Protocol.HTTP({
- url: settings.layers.pop(),
- format: new OpenLayers.Format.KML({
- extractStyles: true,
- extractAttributes: true,
- maxDepth: 2
- })
- })
- });
- map.addLayer(m)
- }
- }
- }
- };
-}());
-
-jekyllMapping.mappingInitialize();
-</script>
\ No newline at end of file
diff --git a/_plugins/jekyll_json.rb b/_plugins/jekyll_json.rb
deleted file mode 100644
index a551876..0000000
--- a/_plugins/jekyll_json.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'json'
-
-module Jekyll
- class JSONTag < Liquid::Tag
-
- def initialize(tag_name, text, tokens)
- @key = text.strip
- @hash_to_jsonify = Jekyll.configuration({})[@key]
- super
- end
- def render(context)
- @data = context['page'][@key]
- # this isn't a sophisticated merge. if there are nested
- # hashes, it'll completely overwrite them (so if you have
- # deeply nested settings in _config.yml that aren't replicated
- # in your page's settings, they'll get blatted).
- @data.each_pair do |k,v|
- @hash_to_jsonify[k] = v
- end
- return @hash_to_jsonify.to_json
- end
- end
-end
-
-Liquid::Template.register_tag('yaml_to_json', Jekyll::JSONTag)
\ No newline at end of file
diff --git a/_plugins/jekyll_mapping.rb b/_plugins/jekyll_mapping.rb
index 6508e9e..2ea0169 100644
--- a/_plugins/jekyll_mapping.rb
+++ b/_plugins/jekyll_mapping.rb
@@ -29,14 +29,29 @@ module Jekyll
if context['page']['mapping']
latitude = context['page']['mapping']['latitude']
longitude = context['page']['mapping']['longitude']
+ layers = context['page']['mapping']['layers']
+ locations = context['page']['mapping']['locations']
+ if layers
+ layers = layers.map { |i| i.to_s }.join(" ")
+ end
+ if locations
+ locations = locations.map { |i| i.to_s }.join(" ")
+ end
+
if @engine == 'google_static'
return "<img src=\"http://maps.googleapis.com/maps/api/staticmap?markers=#{latitude},#{longitude}&size=#{@width}x#{@height}&zoom=#{@zoom}&sensor=false\">"
- elsif @engine == 'google_js' || 'openstreetmap'
- return "<div id=\"jekyll-mapping\" style=\"height:#{@height}px;width:#{@width}px;\"></div>"
+ elsif (@engine == 'google_js') || (@engine == 'openstreetmap')
+ return "<div class=\"jekyll-mapping\"
+ data-latitude=\"#{latitude}\"
+ data-longitude=\"#{longitude}\"
+ data-layers=\"#{layers}\"
+ data-locations=\"#{locations}\"
+ data-title=\"#{context['page']['title']}\"
+ style=\"height:#{@height}px;width:#{@width}px;\"></div>"
end
end
end
end
end
-Liquid::Template.register_tag('render_map', Jekyll::MapTag)
\ No newline at end of file
+Liquid::Template.register_tag('render_map', Jekyll::MapTag)
diff --git a/javascripts/gmaps.js b/javascripts/gmaps.js
new file mode 100644
index 0000000..cb0177b
--- /dev/null
+++ b/javascripts/gmaps.js
@@ -0,0 +1,69 @@
+var jekyllMapping = (function () {
+ return {
+ mappingInitialize: function () {
+ var maps = document.getElementsByClassName("jekyll-mapping");
+ for ( var i = 0; i < maps.length; i++ ) {
+ var zoom = maps[i].getAttribute("data-zoom"),
+ lat = maps[i].getAttribute("data-latitude"),
+ lon = maps[i].getAttribute("data-longitude"),
+ layers = maps[i].getAttribute("data-layers"),
+ title = maps[i].getAttribute("data-title"),
+ options = {
+ zoom: zoom,
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ }, mainMarker;
+
+ if (lat && lon) {
+ options.center = new google.maps.LatLng(lat, lon);
+ map = new google.maps.Map(maps[i], options);
+ mainMarker = new google.maps.Marker({
+ position: options.center,
+ map: map,
+ title: title
+ });
+ } else {
+ options.center = new google.maps.LatLng(0, 0);
+ map = new google.maps.Map(maps[i], options);
+ }
+
+ //TODO: make locations work as well
+ //if (settings.locations instanceof Array) {
+ //var bounds = new google.maps.LatLngBounds(), markers = [], s, l, m;
+ //while (settings.locations.length > 0) {
+ //s = settings.locations.pop();
+ //l = new google.maps.LatLng(s.latitude, s.longitude);
+ //m = new google.maps.Marker({
+ //position: l,
+ //map: map,
+ //title: s.title
+ //});
+ //markers.push(m);
+ //bounds.extend(l);
+ //}
+ //map.fitBounds(bounds);
+ //}
+
+
+ if (layers) {
+ layers = layers.split(' ');
+ var mapLayers = [];
+ while (layers.length > 0){
+ var m = new google.maps.KmlLayer(layers.pop());
+ mapLayers.push(m);
+ m.setMap(map);
+ }
+ }
+ }
+ },
+ loadScript: function () {
+ var script = document.createElement("script");
+ script.type = "text/javascript";
+ script.src = "http://maps.googleapis.com/maps/api/js?key=" +
+ jekyllMappingAPIKey +
+ "&sensor=false&callback=jekyllMapping.mappingInitialize";
+ document.body.appendChild(script);
+ }
+ };
+}());
+
+window.onload = function() { jekyllMapping.loadScript(); };
diff --git a/javascripts/openstreetmaps.js b/javascripts/openstreetmaps.js
new file mode 100644
index 0000000..2c60a1a
--- /dev/null
+++ b/javascripts/openstreetmaps.js
@@ -0,0 +1,62 @@
+var jekyllMapping = (function () {
+ return {
+ mappingInitialize: function() {
+ var maps = document.getElementsByClassName("jekyll-mapping");
+ for ( var i = 0; i < maps.length; i++ ) {
+ var zoom = maps[i].getAttribute("data-zoom"),
+ lat = maps[i].getAttribute("data-latitude"),
+ lon = maps[i].getAttribute("data-longitude"),
+ layers = maps[i].getAttribute("data-layers"),
+ title = maps[i].getAttribute("data-title"),
+ map, markers, center;
+
+ // Set an arbitrary id on the element
+ maps[i].setAttribute('id', 'jekyll-mapping' + i);
+
+ markers = new OpenLayers.Layer.Markers("Markers")
+ map = new OpenLayers.Map('jekyll-mapping' + i);
+ map.addLayer(new OpenLayers.Layer.OSM());
+ map.addLayer(markers);
+ if (lat && lon) {
+ center = new OpenLayers.LonLat(long, lat).transform(
+ new OpenLayers.Projection("EPSG:4326"),
+ new OpenLayers.Projection("EPSG:900913"));
+ map.setCenter(center, zoom);
+ markers.addMarker(new OpenLayers.Marker(center));
+ }
+
+ // TODO: make locations work as well
+ //if (settings.locations instanceof Array) {
+ //var s, l, m, bounds = new OpenLayers.Bounds();
+ //while (settings.locations.length > 0) {
+ //s = settings.locations.pop();
+ //l = new OpenLayers.LonLat(s.longitude, s.latitude).transform( new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
+ //markers.addMarker(new OpenLayers.Marker(l))
+ //bounds.extend(l);
+ //}
+ //map.zoomToExtent(bounds)
+ //}
+
+ if (layers) {
+ layers = layers.split(' ');
+ while (layers.length > 0){
+ var m = new OpenLayers.Layer.Vector("KML", {
+ strategies: [new OpenLayers.Strategy.Fixed()],
+ protocol: new OpenLayers.Protocol.HTTP({
+ url: layers.pop(),
+ format: new OpenLayers.Format.KML({
+ extractStyles: true,
+ extractAttributes: true,
+ maxDepth: 2
+ })
+ })
+ });
+ map.addLayer(m)
+ }
+ }
+ }
+ }
+ };
+}());
+
+window.onload = function() { jekyllMapping.mappingInitialize(); }
diff --git a/sass/_partials.scss b/sass/_partials.scss
new file mode 100644
index 0000000..1b656cb
--- /dev/null
+++ b/sass/_partials.scss
@@ -0,0 +1,9 @@
+@import "partials/header";
+@import "partials/navigation";
+@import "partials/blog";
+@import "partials/sharing";
+@import "partials/syntax";
+@import "partials/archive";
+@import "partials/sidebar";
+@import "partials/footer";
+@import "partials/map";
diff --git a/sass/partials/_map.scss b/sass/partials/_map.scss
new file mode 100644
index 0000000..5dd90a6
--- /dev/null
+++ b/sass/partials/_map.scss
@@ -0,0 +1,21 @@
+.jekyll-mapping {
+ @extend .flex-content;
+ @extend .basic-alignment;
+ @include shadow-box;
+ margin-bottom: 30px;
+ img {
+ -webkit-border-radius: 0px;
+ -moz-border-radius: 0px;
+ -ms-border-radius: 0px;
+ -o-border-radius: 0px;
+ border-radius: 0px;
+ -webkit-box-shadow: rgba(0,0,0,0.15) 0 0px 0px;
+ -moz-box-shadow: rgba(0,0,0,0.15) 0 0px 0px;
+ box-shadow: rgba(0,0,0,0.15) 0 0px 0px;
+ -webkit-box-sizing: content-box;
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
+ border: none;
+ max-width: none;
+ }
+}