leaflet_helper 0.0.2 → 0.0.3

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: fb2e318e079044796d4ead699979deea3b49bdae
4
- data.tar.gz: d2a7a881a2824a0270180a5ef632010504f8825c
3
+ metadata.gz: 5650a8adc68441642df6c25ca2b01dba2a7d3b27
4
+ data.tar.gz: 1cdd5e5a22646db9406608f8e29895e37106c342
5
5
  SHA512:
6
- metadata.gz: 3cba373b4dd9394014eaa00d163b5631adcba322185ae89d04da101dc354b766bbdf9bc88ab418e9d40857cbed7abe5a5b7fc943e2110f9ddfaf4443cdaae56a
7
- data.tar.gz: f6fc47ca34a34c6e980b6c514e19e4302aa22d55ca540faf268a73ce41ae90228ddb2480d5491bdc654612cf736193cbfa475e7102bb79e85d1787a602d1c269
6
+ metadata.gz: f6fba4557327c9c3302c3e00fc781b5794673f80ec21dc3e69ec1dbf81413038c572dd6c5753343054e4eaba7b72a25ab2bbc12262f6da4b296fbd9ef7200ab0
7
+ data.tar.gz: 2e50c27dc53be78a08a08f8304895cc17cd1bd2bac6377cc7dfd3b5f1baa53059193ebfae48f79460150e6bd20bd39606bb197a007f60f0423e5d5b596d78c1f
@@ -5,7 +5,7 @@ require 'leaflet_helper/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "leaflet_helper"
8
- spec.version = '0.0.2'
8
+ spec.version = '0.0.3'
9
9
  spec.authors = ["Dewayne VanHoozer"]
10
10
  spec.email = ["dvanhoozer@gmail.com"]
11
11
 
@@ -15,7 +15,7 @@ module LeafletHelper
15
15
  markers: false
16
16
  }.merge(options)
17
17
 
18
- raise RuntimeError, 'Already initialized' if initialized?
18
+ # raise RuntimeError, 'Already initialized' if initialized?
19
19
  initialized!
20
20
 
21
21
  leaflet_script = <<~EOS
@@ -29,7 +29,7 @@ module LeafletHelper
29
29
 
30
30
  if (ajaxRequest == null) {
31
31
  alert ("This browser does not support HTTP Request");
32
- return;
32
+ // return;
33
33
  }
34
34
 
35
35
  // SMELL: this function is not map specific
@@ -79,6 +79,11 @@ module LeafletHelper
79
79
  leaflet_script = <<~EOS
80
80
  <script>
81
81
 
82
+ var #{var_name};
83
+ var ajaxRequest; // SMELL: not map specific
84
+ var plotlistFor#{id};
85
+ var plotlayersFor#{id} = [];
86
+
82
87
  // set up the map
83
88
  #{var_name} = new L.Map('#{id}');
84
89
 
@@ -123,7 +128,8 @@ module LeafletHelper
123
128
 
124
129
  def add_support_for_markers(id="map", options={})
125
130
  o = {
126
- markers: true
131
+ markers: true,
132
+ route: "#{id}/markers"
127
133
  }.merge(options)
128
134
 
129
135
  var_name = get_var_name(id)
@@ -146,8 +152,10 @@ module LeafletHelper
146
152
  var maxll = bounds.getNorthEast();
147
153
 
148
154
  // FIXME: msg is the URL from which to get markers
149
- var msg = 'leaflet/findbybbox.cgi?format=leaflet&bbox='+minll.lng+','+minll.lat+','+maxll.lng+','+maxll.lat;
155
+ // var msg = 'leaflet/findbybbox.cgi?format=leaflet&bbox='+minll.lng+','+minll.lat+','+maxll.lng+','+maxll.lat;
150
156
 
157
+ var msg = '#{o[:route]}';
158
+
151
159
  ajaxRequest.onreadystatechange = stateChangedFor#{id};
152
160
  ajaxRequest.open('GET', msg, true);
153
161
  ajaxRequest.send(null);
@@ -171,7 +179,7 @@ module LeafletHelper
171
179
 
172
180
  #{var_name}.addLayer(plotmark);
173
181
  plotmark.bindPopup("<h3>" + plotlist[i].name + "</h3>" + plotlist[i].details);
174
- plotlayers.push(plotmark);
182
+ plotlayersFor#{id}.push(plotmark);
175
183
  } // for
176
184
 
177
185
  } // if (ajaxRequest.status == 200)
@@ -182,10 +190,10 @@ module LeafletHelper
182
190
 
183
191
 
184
192
  function removeMarkersFrom#{id}() { // was: removeMarkers
185
- for (i=0; i<plotlayers.length; i++) {
186
- #{var_name}.removeLayer(plotlayers[i]);
193
+ for (i=0; i<plotlayersFor#{id}.length; i++) {
194
+ #{var_name}.removeLayer(plotlayersFor#{id}[i]);
187
195
  }
188
- plotlayers = [];
196
+ plotlayersFor#{id} = [];
189
197
  }
190
198
 
191
199
  </script>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leaflet_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer