leaflet_helper 0.7.7.1 → 1.6.0.0

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
  SHA256:
3
- metadata.gz: 669e7876548d0b732388a0044f9440ec3ef90ef2cdeef57ec2eaf26ce0b787c9
4
- data.tar.gz: dd433bab8d13285a8357be4ac95265dccb4caa77df8a112bb13e9209f1200297
3
+ metadata.gz: e39cd56d64c9d4e49becc41cfe8a290ab52c49b34e4a7f8cbc85e4cad05823e1
4
+ data.tar.gz: 394f7ee255c7c26c7dc2c60ed50506b747726998bdd97aa6e040fe90f4f4dfdd
5
5
  SHA512:
6
- metadata.gz: ef62e595629866c3a110cd2a1df4e47f2257aaad9a1f04a3d4e65a69dd4aa481e846de1fe9174f8f1310fac3b87b9025b67aea470dd97605906c76f579d10d65
7
- data.tar.gz: ae527c374a9decc794e55c8be37f1a3bc8917f2931d7c456d73b88326562e1cc9cbbfaa9035ac4a453d783947572d327a85f5a45a84e4494b6003cd3b343d10d
6
+ metadata.gz: ff88012009b54c0c1a55bb1a8fbf0707073a22d1bba20c61746b9e3a79306d5487eb88f008a16bf5f4fddeb4649d945c99c525361fb3205d04e2433f2a660184
7
+ data.tar.gz: eee1bc278bc9050b19bb82c40d92771c9eca94c10d43597475d5be2b06b22607c6f9e0c15110f7085ed144e680f8c758bd2a243d4ae042965b0b74dd39515993
data/README.md CHANGED
@@ -1,3 +1,12 @@
1
+ # DO NOT USE
2
+
3
+ I wrote this thing a while back as an experiment. At the time it worked well enought for what I had intended. I lost it off of Github. Don't know why. I might have deleted it. Recently I discovered that rubygems.org still had it on file. So I downloaded it, put it back on Github and spent a few hours trying to update it to use the latest versions of LeafletJS and the plugin leaflet.cluster_marker. I failed.
4
+
5
+ This really is a POS-kinda thing. Its not worth your time reviewing.
6
+
7
+ Maybe one of these days I will feel like readdressing the idea of easily interacting with the LeafletJS library and its plugins via pure Ruby. That's not today.
8
+
9
+
1
10
  # LeafletHelper
2
11
 
3
12
  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.
data/example/Gemfile CHANGED
@@ -1,11 +1,13 @@
1
1
  # Gemfile
2
2
 
3
+ require_relative '../lib/version.rb'
4
+
3
5
  source "https://rubygems.org"
4
6
 
5
7
  ruby "2.7.1"
6
8
 
7
9
  # Special Libraries
8
- gem 'leaflet_helper' # A Ruby-wrapper around leaflet.js
10
+ gem 'leaflet_helper', "= #{LeafletHelper::VERSION::GEM}" # A Ruby-wrapper around leaflet.js
9
11
 
10
12
  # Web-app framework
11
13
  gem 'sinatra', require: 'sinatra/base' # Classy web-development dressed in a DSL
data/example/Gemfile.lock CHANGED
@@ -4,7 +4,7 @@ GEM
4
4
  haml (5.1.2)
5
5
  temple (>= 0.8.0)
6
6
  tilt
7
- leaflet_helper (0.7.7.0)
7
+ leaflet_helper (1.6.0.0)
8
8
  mustermann (1.1.1)
9
9
  ruby2_keywords (~> 0.0.1)
10
10
  nio4r (2.5.2)
@@ -29,7 +29,7 @@ PLATFORMS
29
29
 
30
30
  DEPENDENCIES
31
31
  haml
32
- leaflet_helper
32
+ leaflet_helper (= 1.6.0.0)
33
33
  puma
34
34
  sinatra
35
35
  sinatra-partial
data/example/app.rb CHANGED
@@ -2,18 +2,18 @@
2
2
  #########################################################
3
3
  ###
4
4
  ## File: app.rb
5
- ## Desc: An example Sinatra app using LeafletHelper
5
+ ## Desc: An example Sinatra app using LeafletHelper
6
6
  #
7
7
 
8
8
  require 'leaflet_helper'
9
9
 
10
10
  $markers = LeafletHelper::ManageMarkers.new
11
11
 
12
- module TestData
12
+ AREA51_LOCATION = [37.242, -115.8191] # Lat, Long
13
+ DELTA = [15, 15] # NOTE: expresed as integer of real delta +/- 1.5 in lat, long
14
+ # in order to use rand() method
13
15
 
14
- AREA51_LOCATION = [37.242, -115.8191] # Lat, Long
15
- DELTA = [15, 15] # NOTE: expresed as integer of real delta +/- 1.5 in lat, long
16
- # in order to use rand() method
16
+ module TestData
17
17
 
18
18
  CODE_WORDS = [
19
19
  "Magic Carpet",
@@ -43,7 +43,7 @@ module TestData
43
43
  offset << dir * rand(delta.last).to_f / 10.0
44
44
  point = fixed_point.each_with_index.map {|v, x| v + offset[x]}
45
45
 
46
- return { 'lat' => point.first, 'lon' => point.last }
46
+ return { 'lat' => point.first, 'lon' => point.last }
47
47
 
48
48
  end # def get_random_location( fixed_point=AREA51_LOCATION, delta=DELTA )
49
49
  end # class < self
@@ -52,6 +52,17 @@ end # module TestData
52
52
 
53
53
  # Generate a consistent set of test markers
54
54
  $markers.clear
55
+
56
+ $markers.add(
57
+ id: 'Area 51',
58
+ lat: AREA51_LOCATION.first,
59
+ lon: AREA51_LOCATION.last,
60
+ html: <<~EOS
61
+ <h3>Area 51</h3>
62
+ <p>Property for sale. Price Reduced. Owner is motivated to sale quickly.</p>
63
+ EOS
64
+ )
65
+
55
66
  30.times do |x|
56
67
  code_word = TestData.get_random_codeword
57
68
  location = TestData.get_random_location
@@ -103,7 +114,7 @@ module APP
103
114
  set :views, settings.root + '/views'
104
115
 
105
116
  set :partial_template_engine, :haml
106
-
117
+
107
118
  configure do
108
119
  mime_type :html, 'text/html'
109
120
  end
@@ -2,14 +2,17 @@
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
+ require_relative 'lib/version.rb'
6
+
5
7
  Gem::Specification.new do |spec|
6
8
  spec.name = "leaflet_helper"
7
- spec.version = '0.7.7.1' # first three levels match leaflet
9
+ spec.version = LeafletHelper::VERSION::GEM
8
10
  spec.authors = ["Dewayne VanHoozer"]
9
11
  spec.email = ["dvanhoozer@gmail.com"]
10
12
 
11
13
  spec.summary = %q{A Ruby-wrapper around some basic leaflet.js functions}
12
14
  spec.description = <<~EOS
15
+ DO NOT USE.... its a broken toy and I do not have the motivation to fix it.
13
16
  For those of us who don't want to get our hands dirty writing JavaScript (shutter) this library is
14
17
  for you. Actually, its for me, but you can use it if you like. It is a Ruby-wrapper around some
15
18
  basic leaflet.js functions. It uses either Open Street Map or your account on mapbox.com. It handles
@@ -1,8 +1,8 @@
1
1
  # leaflet_helper.rb
2
2
  #
3
- # If you are a front-end developer and a Javascript guru this will
3
+ # If you are a front-end developer and a Javascript guru this will
4
4
  # make you laught. If you are a back-end big-data AI do-er of amazing
5
- # things then this library might be of some use to you. It allows you
5
+ # things then this library might be of some use to you. It allows you
6
6
  # to but maps onto a web-page using simple frameworks. No more NodeJS
7
7
  # or Rails. Use some simple sinatra-based haml pages and voila you got maps.
8
8
  #
@@ -14,6 +14,7 @@
14
14
  # MAPBOX_STYLE_ID
15
15
  # MAPBOX_ACCESS_TOKEN
16
16
 
17
+
17
18
  require 'erb'
18
19
  require 'pathname'
19
20
 
@@ -22,10 +23,11 @@ AREA51 = Struct.new('Location', :latitude, :longitude).new
22
23
  AREA51.latitude = 37.235
23
24
  AREA51.longitude = -115.811111
24
25
 
25
- require 'leaflet_helper/string_template' # Lets do simple string templates
26
- require 'leaflet_helper/manage_markers' # Lets keep track of some markers
27
- require 'leaflet_helper/u' # a utility class
28
- require 'leaflet_helper/l' # wrapper class for LeafletJS
26
+ require_relative 'version.rb'
27
+ require_relative 'leaflet_helper/string_template' # Lets do simple string templates
28
+ require_relative 'leaflet_helper/manage_markers' # Lets keep track of some markers
29
+ require_relative 'leaflet_helper/u' # a utility class
30
+ require_relative 'leaflet_helper/l' # wrapper class for LeafletJS
29
31
 
30
32
 
31
33
  module LeafletHelper
@@ -4,12 +4,16 @@
4
4
 
5
5
  module LeafletHelper
6
6
  class L
7
- VERSION = '0.7.7' # of leaflet.js
8
- JS = "http://cdn.leafletjs.com/leaflet/v#{VERSION}/leaflet.js"
9
- CSS = "http://cdn.leafletjs.com/leaflet/v#{VERSION}/leaflet.css"
7
+ JS = "http://cdn.leafletjs.com/leaflet/v#{LeafletHelper::VERSION::LeafletJS}/leaflet.js"
8
+ CSS = "http://cdn.leafletjs.com/leaflet/v#{LeafletHelper::VERSION::LeafletJS}/leaflet.css"
10
9
 
11
- MarkerClusterJS = "https://raw.githubusercontent.com/Leaflet/Leaflet.markercluster/leaflet-0.7/dist/leaflet.markercluster.js"
12
- MarkerClusterCSS = "https://raw.githubusercontent.com/Leaflet/Leaflet.markercluster/leaflet-0.7/dist/MarkerCluster.css"
10
+ if LeafletHelper::VERSION::MarkerClusterJS.start_with?('0')
11
+ MarkerClusterJS = "https://raw.githubusercontent.com/Leaflet/Leaflet.markercluster/leaflet-0.7/dist/leaflet.markercluster.js"
12
+ MarkerClusterCSS = "https://raw.githubusercontent.com/Leaflet/Leaflet.markercluster/leaflet-0.7/dist/MarkerCluster.css"
13
+ else
14
+ MarkerClusterJS = "https://unpkg.com/leaflet.markercluster@#{LeafletHelper::VERSION::MarkerClusterJS}/dist/leaflet.markercluster.js"
15
+ MarkerClusterCSS = "https://unpkg.com/leaflet.markercluster@#{LeafletHelper::VERSION::MarkerClusterJS}/dist/MarkerCluster.css"
16
+ end
13
17
 
14
18
  # FIXME: Needs to be isolated between maps in a multi-map application.
15
19
  # experiments/maps shows the problem
@@ -22,6 +26,9 @@ module LeafletHelper
22
26
  zoom: 9,
23
27
  min_zoom: 2,
24
28
  max_zoom: 22
29
+ },
30
+ cluster_marker: {
31
+
25
32
  }
26
33
  }
27
34
 
@@ -138,18 +145,34 @@ module LeafletHelper
138
145
 
139
146
  # Allows for the generation of markers on top of the map
140
147
  def add_support_for_markers(id="map", options={})
148
+
149
+ clusterMarkerGroupDefaluts = <<~STRING
150
+ {
151
+ showCoverageOnHover: true, // When you mouse over a cluster it shows the bounds of its markers.
152
+ zoomToBoundsOnClick: true, // When you click a cluster we zoom to its bounds.
153
+ spiderfyOnMaxZoom: true, // When you click a cluster at the bottom zoom level we spiderfy it so you can see all of its markers. (Note: the spiderfy occurs at the current zoom level if all items within the cluster are still clustered at the maximum zoom level or at zoom specified by disableClusteringAtZoom option)
154
+ removeOutsideVisibleBounds: true, // Clusters and markers too far from the viewport are removed from the map for performance.
155
+ spiderLegPolylineOptions: { // Allows you to specify PolylineOptions to style spider legs.
156
+ weight: 1.5,
157
+ color: '#222',
158
+ opacity: 0.5
159
+ }
160
+ }
161
+ STRING
162
+
141
163
  @@defaults[id] = {
142
- id: id,
143
- map_name: get_map_name(id),
144
- route: "#{id}/markers",
145
- markers: true,
146
- cluster: false
164
+ id: id,
165
+ map_name: get_map_name(id),
166
+ route: "#{id}/markers",
167
+ markers: true,
168
+ cluster: false,
169
+ cluster_marker: clusterMarkerGroupDefaluts
147
170
  }.merge(options)
148
171
 
149
172
  o = @@defaults[:leaflet_helper_base].merge( @@defaults[id] )
150
173
 
151
174
  return U.pull_in 'marker_support.js.erb', o
152
- end # def add_support_for_markers(map_id, map_options)
175
+ end # def add_support_for_markers(map_id, map_options)
153
176
 
154
177
 
155
178
  # The Javascript container that has the map for this id
@@ -9,6 +9,12 @@ module LeafletHelper
9
9
  # use ERB to pre-process the file using local binding
10
10
  def pull_in(template_name, options={})
11
11
  options.each { |k,v| instance_variable_set("@#{k}", v) }
12
+
13
+ puts "="*65
14
+ print "pull_in(#{template_name}) option keys: "
15
+ puts options.keys.join(', ')
16
+ puts "="*65
17
+
12
18
  @file_name = LeafletHelper::TEMPLATES + template_name
13
19
  return ERB.new(@file_name.read, 0, '>').result(binding)
14
20
  end # def pull_in(template_name, options={})
@@ -6,8 +6,8 @@
6
6
 
7
7
  <% if @plugins.include? :marker_cluster %>
8
8
  <!-- Leaflet.markercluster -->
9
- <script src="<%= LeafletHelper::L::MarkerClusterJS %>"></script>
10
- <link rel="stylesheet" href="<%= LeafletHelper::L::MarkerClusterCSS %>">
9
+ <script type="text/plain" src="<%= LeafletHelper::L::MarkerClusterJS %>"></script>
10
+ <link type="text/plain" rel="stylesheet" href="<%= LeafletHelper::L::MarkerClusterCSS %>">
11
11
  <% end %>
12
12
 
13
13
  <!-- end <%= @file_name %> -->
data/lib/version.rb ADDED
@@ -0,0 +1,8 @@
1
+
2
+ module LeafletHelper
3
+ module VERSION
4
+ LeafletJS = '1.6.0'
5
+ MarkerClusterJS = '1.4.3'
6
+ GEM = "#{LeafletJS}.0"
7
+ end
8
+ end
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.7.7.1
4
+ version: 1.6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-25 00:00:00.000000000 Z
11
+ date: 2020-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,6 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: |
56
+ DO NOT USE.... its a broken toy and I do not have the motivation to fix it.
56
57
  For those of us who don't want to get our hands dirty writing JavaScript (shutter) this library is
57
58
  for you. Actually, its for me, but you can use it if you like. It is a Ruby-wrapper around some
58
59
  basic leaflet.js functions. It uses either Open Street Map or your account on mapbox.com. It handles
@@ -92,6 +93,7 @@ files:
92
93
  - lib/templates/marker_support.js.erb
93
94
  - lib/templates/set_view.js.erb
94
95
  - lib/templates/show_map.js.erb
96
+ - lib/version.rb
95
97
  homepage: http://github.com/MadBomber/leaflet_helper
96
98
  licenses:
97
99
  - You want it? Its yours!