leaflet_helper 0.0.9 → 0.0.10

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: 7c26717c7956c6e6c22666260c4d4bd09f70e599
4
- data.tar.gz: 6803a55fa2c1a83f06d9992781cf8c95ee7051f1
3
+ metadata.gz: bf271eb73d8d45a0554b309cb31ae8fbc0532587
4
+ data.tar.gz: 64dc8a3971d34c28c47f06664bc1cc4f1b4c85e1
5
5
  SHA512:
6
- metadata.gz: 25229dd0d7ada096415e16b0617ad1d4a6ba14253fa6b01c4612ee9dc8e6ee47fdc0b2a7206ac806f6b3df2978bcdc262a54d693cf271c8f47835361e299a783
7
- data.tar.gz: 4058134528c90a684a907216d63e24d99a57a2bab3772a69ac5e2108853dd019b62c235124d539bf00edea696e16276ff98ff81213f68d6e474d660f18875b9d
6
+ metadata.gz: 50d09b2fc1c139582e1457d58d6828011affc223729d4467c761f892a81fe9830293c2d7c0f21fd40b029b2ee6f92a0bb6898a7735ff7c763f928af27b732e97
7
+ data.tar.gz: 5a26fbcde29920a0a74923c6b44e84c9486189bfa9c08e7b768469dae85f681ec389002d3d3020eec63cfe51b9fc189694b8cc8b78bc102074ae2efa14303d59
data/README.md CHANGED
@@ -1,9 +1,6 @@
1
1
  # LeafletHelper
2
2
 
3
- For those of us who don't want to get our hands dirty writing JavaScript (shutter) this library is
4
- for you. Actually, its for me, but you can use it if you like. It is a Ruby-wrapper around some
5
- basic leaflet.js functions. It uses either Open Street Map or your account on mapbox.com. It handles
6
- markers on maps and the clustering of those markers. It supports multiple maps per web page.
3
+ For those of us who don't want to get our hands dirty writing JavaScript (shutter) this library is for you. Actually, its for me, but you can use it if you like. It is a Ruby-wrapper around some basic leaflet.js functions. It uses either Open Street Map or your account on mapbox.com. It handles markers on maps and the clustering of those markers. It supports multiple maps per web page.
7
4
 
8
5
  This gem has a simple Sinatra-based web application that demonstrates its use.
9
6
 
@@ -21,9 +18,12 @@ bundle install
21
18
 
22
19
  ## Recent Changes
23
20
 
24
- This is it for a while. Its doing all I wanted it to do. There is at least 1 outstanding
25
- issue which prevents good multi-map support. When I fix it, I will bump the version to 0.7.7
26
- to reflect the version of the leaflet.js library that this thing uses.
21
+ This is it for a while. Its doing all I wanted it to do. I will bump the version to 0.7.7 to reflect the version of the leaflet.js library that this thing uses. It looks like leaflet will go to version 1.0.0 soon. When it does I will update this gem to make use of the new versions of the JS libraries.
22
+
23
+ ### v0.0.10 - working
24
+
25
+ * fixed a problem that plauged the multi-map per page defaults collision.
26
+ * changed some defaults which may require updates to existing users
27
27
 
28
28
  ### v0.0.9 - released
29
29
 
@@ -34,13 +34,6 @@ to reflect the version of the leaflet.js library that this thing uses.
34
34
  * Added basic clusters using the leaflet plugin markercluster
35
35
  * refactored some code
36
36
 
37
- ### v0.0.7 - released
38
-
39
- * Added StringTemplate class
40
- Reused the regex from @redpist easy_template gem
41
-
42
- * Fixed typo in ManageMarkers#remove - fat fingered a p[ when all I wanted was a [
43
-
44
37
 
45
38
  ## Installation
46
39
 
@@ -60,112 +53,143 @@ Or install it yourself as:
60
53
 
61
54
  ## Usage
62
55
 
63
- Here is another example of how to use LeafletHelper with multiple maps on a webpage [https://github.com/MadBomber/experiments/tree/master/maps]
56
+ Here is [another example](https://github.com/MadBomber/experiments/tree/master/maps) of how to use LeafletHelper with multiple maps on a webpage.
64
57
 
65
- The views/layout.haml and views/index.haml show how to use the leaflet_helper. Of course you
66
- have to require the gem in the main app.rb file in order for it to be available in the views. This
67
- sinatra app also shows how to use markers on top of the main map layers.
58
+ The views/layout.haml and views/index.haml show how to use the leaflet_helper. Of course you have to require the gem in the main app.rb file in order for it to be available in the views. This sinatra app also shows how to use markers on top of the main map layers.
68
59
 
69
60
  Just about all of the methods in this library emit javascript source code.
70
61
 
71
62
  ### LeafletHelper::L.init(options={})
72
63
 
73
- The 'init' method is used to insert the leaflet.js script and leaflet.css stylesheet.
74
- It is used in the 'head' part of a webpage. For example if you are use Sinatra and haml then
75
- the 'layout.haml' file might look like this:
64
+ The 'init' method is used to insert the leaflet.js script and leaflet.css stylesheet. It is used in the 'head' part of a webpage. For example if you are use Sinatra and haml then the 'layout.haml' file might look like this:
76
65
 
77
66
 
78
67
  ```ruby
79
68
  %html
80
69
  %head
81
- = LeafletHelper::L.init(options)
70
+ = LeafletHelper::L.init({ plugins: [:marker_cluster]})
82
71
  ```
83
72
 
73
+ The only Leaflet plugin currently supported is [`markercluster`](https://github.com/Leaflet/Leaflet.markercluster)
74
+
84
75
  #### options
85
76
 
86
- The 'options' is a hash. It defaults to:
77
+ The global defaults for all maps are:
87
78
 
88
79
  ```ruby
89
- {
90
- openstreetmap: true, # either Open Street Maps or
91
- mapbox: false, # Mapbox.com is used as the map tile provider; not both
92
- markers: false, # set to true to make use of markers on top of maps
93
- cluster: false, # set to true to load the markercluster plugin
94
- latitude: AREA51.latitude, # default map center
95
- longitude: AREA51.longitude, # default map center
96
- zoom: 9,
97
- min_zoom: 2,
98
- max_zoom: 22
99
- }
100
-
80
+ plugins: [],
81
+ latitude: AREA51.latitude,
82
+ longitude: AREA51.longitude,
83
+ zoom: 9,
84
+ min_zoom: 2,
85
+ max_zoom: 22,
86
+ cluster_marker: '... see below ...'
101
87
  ```
102
88
 
103
- There is also a `cluster_marker` default used to create markers for clusters. The
104
- default function is maintained in the file [cluster_icon_create_function.js.erb](https://github.com/MadBomber/leaflet_helper/blob/master/lib/templates/cluster_icon_create_function.js.erb).
89
+ A `cluster_marker` default is added when the `markercluster` plugin is included. It is used to create markers for clusters. The default function is maintained in the file [cluster_icon_create_function.js.erb](https://github.com/MadBomber/leaflet_helper/blob/master/lib/templates/cluster_icon_create_function.js.erb). This default can be overriden by every map.
105
90
 
106
91
 
107
92
  ### LeafletHelper::L.place_map_here(id='map', options={})
108
93
 
109
- The `place_map_here` method is used to insert the HTML `<div>` tag into the
110
- body of a webpage. This is the HTML container which will host the map image
111
- managed by the LeafletJS library. If is possible to have several map images
112
- displayed on the same webpage; HOWEVER, each map image MUST have a different
113
- id ... because they MUST be unique ... because they MUST BE DIFFERENT thats why.
94
+ The `place_map_here` method is used to insert the HTML `<div>` tag into the body of a webpage. This is the HTML container which will host the map image managed by the LeafletJS library. If is possible to have several map images displayed on the same webpage; HOWEVER, each map image MUST have a different id ... because they MUST be unique ... because they MUST BE DIFFERENT thats why.
95
+
96
+ ```ruby
97
+ %html
98
+ %body
99
+ = LeafletHelper::L.place_map_here('treasure_map', style: 'width: 400px; height: 400px')
100
+ ```
101
+
102
+ If you accept all of the defaults then you can just do:
103
+
104
+ ```ruby
105
+ %html
106
+ %body
107
+ = LeafletHelper::L.place_map_here
108
+ ```
109
+
110
+ This will result in a `<div id='map'></div>` element being inserted into your HTML code. Use CSS to style the map anyway you want if you're into that sort of thing.
114
111
 
115
112
  #### id
116
113
 
117
- Yep, its a string that uniquely identifies the HTML `<div>` component
118
- that holds the generated map graphic managed by the LeafletJS javascript
119
- library.
114
+ Yep, its a string that uniquely identifies the HTML `<div>` component that holds the generated map graphic managed by the LeafletJS javascript library.
120
115
 
121
116
  #### options
122
117
 
123
118
  Defaults:
124
119
 
125
120
  ```ruby
126
- o = {
127
121
  style: "width: 1200px; height: 400px"
128
- }.merge(options)
129
122
  ```
130
123
 
131
- Of course you could just use some CSS to add anything you want. But if you
132
- are an inline kinda UI/UX newbie then the options are for you.
124
+ Of course you could just use some CSS to add anything you want. But if you are an inline kinda UI/UX newbie then the options are for you.
133
125
 
134
126
  ### LeafletHelper::L.show_map(id="map", options={})
135
127
 
136
- This method is used at the end of the body component of the HTML webpage. Why? you
137
- ask. Because thats how we did it in the old days to make sure that the entire webpage
138
- was loaded before doing stuff on it. You hotshot javascripters know how its done
139
- the "right" way. I'm sure you have a pull-request ready to go to help out us
140
- old back-end geezers.
128
+ This method is used at the end of the body component of the HTML webpage. Why? you ask. Because thats how we did it in the old days to make sure that the entire webpage was loaded before doing stuff on it. You hotshot javascripters know how its done the "right" way. I'm sure you have a pull-request ready to go to help out this old back-end geezer.
129
+
130
+ This method generates javascript source code. You must explicitly specify the tile layer and wither you want to use markers and wither you want those markers to be clustered. Some typical examples are shown below.
141
131
 
142
- This method generates javascript source code that also includes the same javascript that
143
- is generated by the LeafletHelper::L.set_view method. That may change.
132
+ Use Open Street Map as the background tile layer with un-clustered markers:
133
+
134
+ ```ruby
135
+ %html
136
+ %body
137
+ Yada Yada Yada
138
+ = LeafletHelper::L.show_map( 'treasure_map', openstreetmap: true, markers: true )
139
+ ```
140
+
141
+ Use a `mapbox.com` project as the background tile layer with clustered markers:
142
+
143
+ ```ruby
144
+ %html
145
+ %body
146
+ Yo Ho Ho, and a bottle of rum.
147
+ = LeafletHelper::L.show_map( 'treasure_map', mapbox: true, markers: true, cluster: true )
148
+ ```
144
149
 
145
150
  #### id
146
151
 
147
- Yep, its a string that uniquely identifies the HTML `<div>` component
148
- that holds the generated map graphic managed by the LeafletJS javascript
149
- library.
152
+ Yep, its a string that uniquely identifies the HTML `<div>` component that holds the generated map graphic managed by the LeafletJS javascript library.
150
153
 
151
154
  #### options
152
155
 
153
156
  Defaults:
154
157
 
155
158
  ```ruby
156
- o = @@defaults.merge({
157
- id: id,
158
- map_name: get_map_name(id),
159
- route: "#{id}/markers"
160
- }.merge(options))
159
+ id: id,
160
+ map_name: get_map_name(id),
161
+ markers: false,
162
+ cluster: false
163
+ ```
164
+
165
+ The method `get_map_name` currently prepends 'lh_' to the map id passed into the method. You can monkey patch this method to be something different. For example:
166
+
167
+ ```ruby
168
+ require 'leaflet_helper'
169
+
170
+ module LeafletHelper
171
+ class L
172
+ def self.get_map_name(id)
173
+ 'monkey_patching_should_be_avoided_' + id
174
+ end
175
+ end
176
+ end
161
177
  ```
162
178
 
179
+ What I'd do if I didn't like the default `map_name` is to avoid the howler monkeys and just make my own `map_name` part of the options passed to `show_map` like this:
180
+
181
+ ```ruby
182
+ %html
183
+ %body
184
+ Yo Ho Ho, and a few kegs of rum.
185
+ = LeafletHelper::L.show_map( 'treasure_map', map_name: 'hereBeGold', mapbox: true, markers: true, cluster: true )
186
+ ```
163
187
 
164
188
  ## System Environment Variables
165
189
 
166
190
  If you are going to use `mapbox.com` as a map tile provider you will need an account on that service.
167
191
 
168
- The following system environment variables are used in loading your sceen from mapbox.com:
192
+ The following system environment variables are used in loading your scene from mapbox.com:
169
193
 
170
194
  * MAPBOX_URL
171
195
  * MAPBOX_USER
@@ -175,11 +199,9 @@ The following system environment variables are used in loading your sceen from m
175
199
 
176
200
  ## Development
177
201
 
178
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
202
+ Fork the repo, make a branch for your work, do something, check in your branch then generate a pull request.
179
203
 
180
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
181
-
182
- Of course if that doesn't work try something else. I'm not any good a javascript; if you are, send me some pull requests to improve my naive notions.
204
+ Of course if that doesn't work try something else. I'm not any good at javascript; if you are, send me some pull requests to improve my naive notions.
183
205
 
184
206
  ## Contributing
185
207
 
@@ -189,4 +211,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/MadBom
189
211
  ## License
190
212
 
191
213
  You want it? Its yours!
192
-
data/example/Gemfile.lock CHANGED
@@ -3,7 +3,7 @@ GEM
3
3
  specs:
4
4
  haml (4.0.7)
5
5
  tilt
6
- leaflet_helper (0.0.9)
6
+ leaflet_helper (0.0.10)
7
7
  puma (3.4.0)
8
8
  rack (1.6.4)
9
9
  rack-protection (1.5.3)
@@ -3,7 +3,7 @@
3
3
  %html
4
4
  %head
5
5
  %title Application by VanHoozer
6
- = LeafletHelper::L.init({ openstreetmap: true, mapbox: false, markers: true, cluster: true })
6
+ = LeafletHelper::L.init({ plugins: [ :marker_cluster ] })
7
7
 
8
8
 
9
9
  %body
@@ -20,4 +20,4 @@
20
20
  #footer
21
21
  = partial :footer
22
22
 
23
- = LeafletHelper::L.show_map('my_wonderful_map', { route: "my_wonderful_map/markers" })
23
+ = LeafletHelper::L.show_map('my_wonderful_map', { openstreetmap: true, mapbox: false, route: "my_wonderful_map/markers", markers: true, cluster: true })
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "leaflet_helper"
7
- spec.version = '0.0.9'
7
+ spec.version = '0.0.10'
8
8
  spec.authors = ["Dewayne VanHoozer"]
9
9
  spec.email = ["dvanhoozer@gmail.com"]
10
10
 
@@ -13,30 +13,30 @@ module LeafletHelper
13
13
 
14
14
  # FIXME: Needs to be isolated between maps in a multi-map application.
15
15
  # experiments/maps shows the problem
16
- @@defaults = { # the options from L#init
17
- openstreetmap: true,
18
- mapbox: false,
19
- markers: false,
20
- cluster: false,
21
- latitude: AREA51.latitude,
22
- longitude: AREA51.longitude,
23
- zoom: 9,
24
- min_zoom: 2,
25
- max_zoom: 22
16
+ @@defaults = {
17
+ leaflet_helper_base:
18
+ { # the options from L#init
19
+ plugins: [],
20
+ latitude: AREA51.latitude,
21
+ longitude: AREA51.longitude,
22
+ zoom: 9,
23
+ min_zoom: 2,
24
+ max_zoom: 22
25
+ }
26
26
  }
27
27
 
28
-
29
28
  class << self
30
29
 
31
30
  # intended for the the head section of a web page
32
31
  def init(options={})
33
- @@defaults.merge! options
32
+ @@defaults[:leaflet_helper_base].merge! options
34
33
 
35
- if cluster? && @@defaults[:cluster_marker].nil?
36
- @@defaults[:cluster_marker] = U.pull_in('cluster_icon_create_function.js.erb',{})
34
+ if @@defaults[:leaflet_helper_base][:plugins].include?(:cluster) &&
35
+ @@defaults[:leaflet_helper_base][:cluster_marker].nil?
36
+ @@defaults[:leaflet_helper_base][:cluster_marker] = U.pull_in('cluster_icon_create_function.js.erb')
37
37
  end
38
38
 
39
- return U.pull_in 'head.html.erb', @@defaults
39
+ return U.pull_in 'head.html.erb', @@defaults[:leaflet_helper_base]
40
40
  end # def init
41
41
 
42
42
 
@@ -61,20 +61,26 @@ module LeafletHelper
61
61
  # Intended for the body at the bottom
62
62
  # see the example for, er uh, an example
63
63
  def show_map(id="map", options={})
64
- o = @@defaults.merge({
64
+ @@defaults[id] = {
65
65
  id: id,
66
66
  map_name: get_map_name(id),
67
- route: "#{id}/markers"
68
- }.merge(options))
67
+ markers: false,
68
+ cluster: false
69
+ }.merge(options)
70
+
71
+ o = @@defaults[:leaflet_helper_base].merge( @@defaults[id] )
69
72
 
70
73
  script = "<script>\n"
71
74
  script += U.pull_in 'show_map.js.erb', o
72
75
  script += set_view(id, o)
73
76
 
74
77
  # SMELL: why can't you have both OSM and Mapbox?
75
- script += add_openstreetmap_layer(id, o) if openstreetmap? && !mapbox?
76
- script += add_mapbox_layer(id, o) if mapbox? && !openstreetmap?
77
- script += add_support_for_markers(id, o) if markers?
78
+ # If I renember right there is a way within Mapbox Studio to incorporate
79
+ # an open street map layer. There is also this:
80
+ # http://gis.stackexchange.com/questions/116205/multiple-simultaneous-tilelayers-in-leaflet
81
+ script += add_openstreetmap_layer(id, o) if o[:openstreetmap] && !o[:mapbox]
82
+ script += add_mapbox_layer(id, o) if o[:mapbox] && !o[:openstreetmap]
83
+ script += add_support_for_markers(id, o) if o[:markers]
78
84
 
79
85
  script += "</script>\n"
80
86
 
@@ -84,10 +90,12 @@ module LeafletHelper
84
90
 
85
91
  # Center an existing map to a specific location
86
92
  def set_view(id='map', options={})
87
- o = @@defaults.merge({
93
+ @@defaults[id] = {
88
94
  id: id,
89
95
  map_name: get_map_name(id)
90
- }.merge(options))
96
+ }.merge(options)
97
+
98
+ o = @@defaults[:leaflet_helper_base].merge( @@defaults[id] )
91
99
 
92
100
  return U.pull_in 'set_view.js.erb', o
93
101
  end # def set_view(id='map', options={})
@@ -95,13 +103,15 @@ module LeafletHelper
95
103
 
96
104
  # The default tile provider is Open Street Map project
97
105
  def add_openstreetmap_layer(id="map", options={})
98
- @@defaults[:openstreetmap] = true
99
- o = @@defaults.merge({
106
+ @@defaults[id] = {
100
107
  id: id,
101
108
  map_name: get_map_name(id),
109
+ openstreetmap: true,
102
110
  osm_url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
103
111
  osm_attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors'
104
- }.merge(options))
112
+ }.merge(options)
113
+
114
+ o = @@defaults[:leaflet_helper_base].merge( @@defaults[id] )
105
115
 
106
116
  return U.pull_in 'add_openstreetmap_layer.js.erb', o
107
117
  end # def add_openstreetmap_layer(id="map", options={})
@@ -109,15 +119,18 @@ module LeafletHelper
109
119
 
110
120
  # NOTE: To use mapbox you must have an account
111
121
  def add_mapbox_layer(id="map", options={})
112
- o = @@defaults.merge({
122
+ @@defaults[id] = {
113
123
  id: id,
114
124
  map_name: get_map_name(id),
125
+ mapbox: true,
115
126
  mapbox_url: ENV['MAPBOX_URL'] || "https://api.mapbox.com/styles/v1/{mbUser}/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}",
116
127
  mapbox_user: ENV['MAPBOX_USER'] || "your.mapbox.user.account",
117
128
  mapbox_style_id: ENV['MAPBOX_STYLE_ID'] || "your.mapbox.project.id",
118
129
  mapbox_access_token: ENV['MAPBOX_ACCESS_TOKEN'] || "your.mapbox.access.token",
119
130
  mapbox_attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
120
- }.merge(options))
131
+ }.merge(options)
132
+
133
+ o = @@defaults[:leaflet_helper_base].merge( @@defaults[id] )
121
134
 
122
135
  return U.pull_in 'add_mapbox_layer.js.erb', o
123
136
  end # def add_mapbox_layer(id="map", options={})
@@ -125,11 +138,15 @@ module LeafletHelper
125
138
 
126
139
  # Allows for the generation of markers on top of the map
127
140
  def add_support_for_markers(id="map", options={})
128
- o = @@defaults.merge({
129
- id: id,
130
- map_name: get_map_name(id),
131
- route: "#{id}/markers"
132
- }.merge(options))
141
+ @@defaults[id] = {
142
+ id: id,
143
+ map_name: get_map_name(id),
144
+ route: "#{id}/markers",
145
+ markers: true,
146
+ cluster: false
147
+ }.merge(options)
148
+
149
+ o = @@defaults[:leaflet_helper_base].merge( @@defaults[id] )
133
150
 
134
151
  return U.pull_in 'marker_support.js.erb', o
135
152
  end # def add_support_for_markers(map_id, map_options)
@@ -141,25 +158,10 @@ module LeafletHelper
141
158
  end
142
159
 
143
160
 
144
- def openstreetmap?
145
- @@defaults[:openstreetmap]
146
- end
147
-
148
- def mapbox?
149
- @@defaults[:mapbox]
150
- end
151
-
152
- def markers?
153
- @@defaults[:markers]
154
- end
155
-
156
- def cluster?
157
- @@defaults[:cluster]
158
- end
159
161
 
160
162
  # LeafletHelper::U needs access to the L's class variable
161
- def defaults
162
- @@defaults
163
+ def defaults(id)
164
+ @@defaults[id]
163
165
  end
164
166
 
165
167
  end # class << self
@@ -13,11 +13,6 @@ module LeafletHelper
13
13
  return ERB.new(@file_name.read, 0, '>').result(binding)
14
14
  end # def pull_in(template_name, options={})
15
15
 
16
- # provide ERB in #pull_in with visibility into class L
17
- def cluster?
18
- LeafletHelper::L.defaults[:cluster]
19
- end # def cluster?
20
-
21
16
  end # class << self
22
17
  end # class U
23
18
  end # module LeafletHelper
@@ -1,7 +1,7 @@
1
1
  <!-- begin <%= @file_name %> -->
2
2
 
3
3
  L.tileLayer(
4
- '<%= @url %>',
4
+ '<%= @mapbox_url %>',
5
5
  {
6
6
  mbUser: '<%= @mapbox_user %>',
7
7
  attribution: '<%= @mapbox_attribution %>',
@@ -4,7 +4,7 @@
4
4
  <script src="<%= LeafletHelper::L::JS %>"></script>
5
5
  <link rel="stylesheet" href="<%= LeafletHelper::L::CSS %>">
6
6
 
7
- <% if @cluster %>
7
+ <% if @plugins.include? :marker_cluster %>
8
8
  <!-- Leaflet.markercluster -->
9
9
  <script src="<%= LeafletHelper::L::MarkerClusterJS %>"></script>
10
10
  <link rel="stylesheet" href="<%= LeafletHelper::L::MarkerClusterCSS %>">
@@ -47,7 +47,7 @@ function stateChangedFor<%= @id %>() {
47
47
  // if AJAX returned a list of markers, add them to the map
48
48
  if (ajaxRequestFor<%= @id %>.readyState == 4) {
49
49
 
50
- <% if cluster? %>
50
+ <% if @cluster %>
51
51
  var markersFor<%= @id %> = L.markerClusterGroup(
52
52
  <%= @cluster_marker %>
53
53
  );
@@ -63,15 +63,9 @@ function stateChangedFor<%= @id %>() {
63
63
  var plotmark = new L.Marker(plotll);
64
64
  plotmark.data = plotlist[i];
65
65
 
66
- // SMELL: Is each marker in a different layer? Wouldn't it
67
- // be better to have all markers in the same layer?
68
- // With all markers in the same layer we could then do ...
69
- // markerLayer.add(markers).addTo(map);
70
- // map.fitBounds(markerLayer.getBounds());
71
-
72
66
  plotmark.bindPopup(plotlist[i].html);
73
67
 
74
- <% if cluster? %>
68
+ <% if @cluster %>
75
69
  markersFor<%= @id %>.addLayer(plotmark);
76
70
  <% else %>
77
71
  <%= @map_name %>.addLayer(plotmark);
@@ -80,7 +74,7 @@ function stateChangedFor<%= @id %>() {
80
74
 
81
75
  } // for
82
76
 
83
- <% if cluster? %>
77
+ <% if @cluster %>
84
78
  <%= @map_name %>.addLayer(markersFor<%= @id %>);
85
79
  <% end %>
86
80
 
@@ -1,11 +1,17 @@
1
1
  <!-- begin <%= @file_name %> -->
2
2
 
3
- var <%= @map_name %> = new L.Map('<%= @id %>');
3
+ var <%= @map_name %> = new L.Map('<%= @id %>',
4
+ {
5
+ zoom: <%= @zoom %>,
6
+ minZoom: <%= @min_zoom %>,
7
+ maxZoom: <%= @max_zoom %>
8
+ }
9
+ );
4
10
 
5
- // SMELL: These 3 vars are only used with markers so why are they here?
11
+ <% if @markers %>
6
12
  var ajaxRequestFor<%= @id %>;
7
13
  var plotlistFor<%= @id %>;
8
14
  var plotlayersFor<%= @id %> = [];
15
+ <% end %>
9
16
 
10
17
  <!-- end <%= @file_name %> -->
11
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leaflet_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-17 00:00:00.000000000 Z
11
+ date: 2016-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler