jekyll-maps 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c779e67a99b76a3655d973fd5671d068d0709d7a
4
- data.tar.gz: f5a9d0b3a557ec8c00cd7193b592b9c4f384fbfc
3
+ metadata.gz: 2a74fcbcd8ef290f24136b57ed4c40426c8dcbbb
4
+ data.tar.gz: 6efa49c7799005c02fd2c9871bf57bb8248fe20f
5
5
  SHA512:
6
- metadata.gz: fd731507ed453f4f7d097f615a1373b8d3ed37fa6e2e9207e2bf996d27fce64d2790f633fb6c55f0bc2856fe5c8d995bc8f6643c202c9341522ad06a637c861e
7
- data.tar.gz: 0b4c9c70d6894ea3354da45fa0f02050e8abde7d4dad9c9e618f20b8aa9daa9ca5c79a9670b8e7e143d358265e822080b517aa73ffdf10fe4c0658489033705c
6
+ metadata.gz: eb263df2652df18d22ab3c1e45bcdf2e4970f66c00f12bbb06278883b4cba1e6fffcf2b5a3225916448550fa21f8989fe9fef1ce0e2fc4a62894e40fdaf3d534
7
+ data.tar.gz: f32958144f5e1b24ea21d63dba885dc6ab2e44eab3f2066295c95bbbf7f9e026f3f8471fed452e77a16c580683b4a9d5e513a6d6a2f8b556e656dbc65e480ac1
data/History.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.1.2 / 2016-07-22
2
+
3
+ * configurable marker cluster
4
+
1
5
  ## 1.1.1 / 2016-07-20
2
6
 
3
7
  * configure GoogleMaps API key from _config.yml
data/README.md CHANGED
@@ -6,7 +6,10 @@
6
6
  [![Test Coverage](https://codeclimate.com/github/ayastreb/jekyll-maps/badges/coverage.svg)](https://codeclimate.com/github/ayastreb/jekyll-maps/coverage)
7
7
  [![Dependency Status](https://gemnasium.com/badges/github.com/ayastreb/jekyll-maps.svg)](https://gemnasium.com/github.com/ayastreb/jekyll-maps)
8
8
 
9
- Easily embed Google Maps with locations from your Jekyll posts, pages or data files.
9
+ Jekyll Maps is a plugin that allows you to easily create different maps on your Jekyll site pages.
10
+ It allows you to select which points to display on the map with different filters.
11
+
12
+ GoogleMaps Marker Clusterer can be used if you have many points within close proximity.
10
13
 
11
14
  ## Installation
12
15
 
@@ -25,6 +28,8 @@ Easily embed Google Maps with locations from your Jekyll posts, pages or data fi
25
28
 
26
29
  ## Usage
27
30
 
31
+ ### Data Source
32
+
28
33
  First, add location information to your posts YAML front-matter:
29
34
 
30
35
  ```yml
@@ -60,17 +65,42 @@ You can configure map's dimensions and assign custom CSS class to the element:
60
65
  ```
61
66
  {% google_map width:100% height:400 class:my-map %}
62
67
  ```
68
+
69
+ ### Filters
63
70
 
64
- You can also filter which locations to display on the map!
65
-
66
- For instance, following tag will only display points from documents which have `lang: en` in their front-matter data.
71
+ You can also filter which locations to display on the map!<br/>
72
+ For instance, following tag will only display locations from documents which have `lang: en` in their front-matter data.
67
73
 
68
74
  ```
69
75
  {% google_map lang:en %}
70
76
  ```
71
77
 
78
+ ### Marker Cluster
79
+
80
+ By default [Marker Clusterer](https://github.com/googlemaps/js-marker-clusterer) is enabled.
81
+ If you have many markers on the map, it will group them and show icon with the count of markers in each cluster - [See example](https://googlemaps.github.io/js-marker-clusterer/examples/advanced_example.html)
82
+
83
+ If you don't want to use marker cluster, you can disable it globally in `_config.yml`:
84
+
85
+ ```yml
86
+ maps:
87
+ google:
88
+ marker_cluster:
89
+ enabled: false
90
+ ```
91
+
92
+ Or you can disable it per single map tag:
93
+
94
+ ```
95
+ {% google_map no_cluster %}
96
+ ```
97
+
72
98
  If you have any questions or proposals - open up an [issue](https://github.com/ayastreb/jekyll-maps/issues/new)!
73
99
 
100
+ ## Examples
101
+
102
+ Want to see it in action? Check out [Demo Page](https://ayastreb.github.io/jekyll-maps/#examples)!
103
+
74
104
  ## Contributing
75
105
 
76
106
  1. Fork it (https://github.com/ayastreb/jekyll-maps/fork)
data/jekyll-maps.gemspec CHANGED
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.add_dependency "jekyll", "~> 3.0"
20
20
 
21
21
  spec.add_development_dependency "rake", "~> 11.0"
22
- spec.add_development_dependency "rspec", "~> 3.0"
22
+ spec.add_development_dependency "rspec", "~> 3.5"
23
23
  spec.add_development_dependency "rubocop", "~> 0.41"
24
24
  end
@@ -29,9 +29,10 @@ var jekyllMaps = (function () {
29
29
  *
30
30
  * @param String id
31
31
  * @param Array locations
32
+ * @param Boolean useCluster
32
33
  */
33
- function register(id, locations) {
34
- this.data.push({id: id, locations: locations});
34
+ function register(id, locations, useCluster) {
35
+ this.data.push({id: id, locations: locations, useCluster: useCluster});
35
36
  this.render();
36
37
  }
37
38
 
@@ -48,8 +49,10 @@ var jekyllMaps = (function () {
48
49
  markers = data.locations.map(createMarker);
49
50
 
50
51
  map.fitBounds(bounds);
51
- this.maps.push({map: map, markers: markers});
52
- this.processCluster();
52
+ if (data.useCluster) {
53
+ this.maps.push({map: map, markers: markers});
54
+ this.processCluster();
55
+ }
53
56
  }
54
57
 
55
58
  function createMarker(location) {
@@ -70,8 +73,9 @@ var jekyllMaps = (function () {
70
73
  }
71
74
  }
72
75
 
73
- function initializeCluster() {
76
+ function initializeCluster(settings) {
74
77
  this.clusterReady = true;
78
+ this.clusterSettings = settings || {};
75
79
  this.processCluster();
76
80
  }
77
81
 
@@ -81,7 +85,7 @@ var jekyllMaps = (function () {
81
85
  while (this.maps.length > 0) {
82
86
  var obj = this.maps.pop();
83
87
  new MarkerClusterer(obj.map, obj.markers, {
84
- gridSize: 25,
88
+ gridSize: this.clusterSettings.grid_size || 25,
85
89
  imagePath: 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m'
86
90
  });
87
91
  }
@@ -16,14 +16,34 @@ module Jekyll
16
16
 
17
17
  private
18
18
  def api_code
19
- api_key = @config.fetch("maps", {}).fetch("google", {}).fetch("api_key", "")
20
19
  <<HTML
21
20
  <script type='text/javascript'>
22
21
  #{js_lib_contents}
23
22
  </script>
23
+ #{load_google_maps_api}
24
+ #{load_marker_cluster}
25
+ HTML
26
+ end
27
+
28
+ private
29
+ def load_google_maps_api
30
+ api_key = @config.fetch("maps", {})
31
+ .fetch("google", {})
32
+ .fetch("api_key", "")
33
+ <<HTML
24
34
  <script async defer src='https://maps.googleapis.com/maps/api/js?key=#{api_key}&callback=jekyllMaps.initializeMap'></script>
35
+ HTML
36
+ end
37
+
38
+ private
39
+ def load_marker_cluster
40
+ settings = @config.fetch("maps", {})
41
+ .fetch("google", {})
42
+ .fetch("marker_cluster", {})
43
+ return unless settings.fetch("enabled", true)
44
+ <<HTML
25
45
  <script async defer src='https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/src/markerclusterer.js'
26
- onload='jekyllMaps.initializeCluster()'></script>
46
+ onload='jekyllMaps.initializeCluster(#{settings.to_json})'></script>
27
47
  HTML
28
48
  end
29
49
 
@@ -13,12 +13,13 @@ module Jekyll
13
13
 
14
14
  def render(context)
15
15
  locations = @finder.find(context.registers[:site])
16
+ use_cluster = @args[:flags][:no_cluster] ? "false" : "true"
16
17
  @args[:attributes][:id] ||= SecureRandom.uuid
17
18
 
18
19
  <<HTML
19
20
  <div #{render_attributes}></div>
20
21
  <script type='text/javascript'>
21
- #{JS_LIB_NAME}.register('#{@args[:attributes][:id]}', #{locations.to_json});
22
+ #{JS_LIB_NAME}.register('#{@args[:attributes][:id]}', #{locations.to_json}, #{use_cluster});
22
23
  </script>
23
24
  HTML
24
25
  end
@@ -2,6 +2,9 @@ module Jekyll
2
2
  module Maps
3
3
  class OptionsParser
4
4
  OPTIONS_SYNTAX = %r!([^\s]+)\s*:\s*([^\s]+)!
5
+ ALLOWED_FLAGS = %w(
6
+ no_cluster
7
+ ).freeze
5
8
  ALLOWED_ATTRIBUTES = %w(
6
9
  id
7
10
  width
@@ -13,7 +16,8 @@ module Jekyll
13
16
  def parse(raw_options)
14
17
  options = {
15
18
  :attributes => {},
16
- :filters => {}
19
+ :filters => {},
20
+ :flags => {}
17
21
  }
18
22
  raw_options.scan(OPTIONS_SYNTAX).each do |key, value|
19
23
  value = value.split(",") if value.include?(",")
@@ -23,6 +27,9 @@ module Jekyll
23
27
  options[:filters][key] = value
24
28
  end
25
29
  end
30
+ ALLOWED_FLAGS.each do |key|
31
+ options[:flags][key.to_sym] = true if raw_options.include?(key)
32
+ end
26
33
  options
27
34
  end
28
35
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Maps
3
- VERSION = "1.1.1".freeze
3
+ VERSION = "1.1.2".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-maps
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoliy Yastreb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-20 00:00:00.000000000 Z
11
+ date: 2016-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '3.5'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '3.5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement