leaflet_helper 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/leaflet_helper.gemspec +1 -1
- data/lib/leaflet_helper.rb +16 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5650a8adc68441642df6c25ca2b01dba2a7d3b27
|
4
|
+
data.tar.gz: 1cdd5e5a22646db9406608f8e29895e37106c342
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6fba4557327c9c3302c3e00fc781b5794673f80ec21dc3e69ec1dbf81413038c572dd6c5753343054e4eaba7b72a25ab2bbc12262f6da4b296fbd9ef7200ab0
|
7
|
+
data.tar.gz: 2e50c27dc53be78a08a08f8304895cc17cd1bd2bac6377cc7dfd3b5f1baa53059193ebfae48f79460150e6bd20bd39606bb197a007f60f0423e5d5b596d78c1f
|
data/leaflet_helper.gemspec
CHANGED
data/lib/leaflet_helper.rb
CHANGED
@@ -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
|
-
|
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<
|
186
|
-
#{var_name}.removeLayer(
|
193
|
+
for (i=0; i<plotlayersFor#{id}.length; i++) {
|
194
|
+
#{var_name}.removeLayer(plotlayersFor#{id}[i]);
|
187
195
|
}
|
188
|
-
|
196
|
+
plotlayersFor#{id} = [];
|
189
197
|
}
|
190
198
|
|
191
199
|
</script>
|