leafleter 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/lib/leafleter.rb +39 -29
  4. metadata +19 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 547aab3050fc3bdde8c4836ff7f00a0195a24605
4
- data.tar.gz: 35d2971b4dbea57cfa0c75384cb5619072eb74e0
3
+ metadata.gz: a9c6d60b6b959f1ab7ab8be9c9f6e3adbfca92bb
4
+ data.tar.gz: 972f1b767052555e2eb225a06f005ac2120c7e23
5
5
  SHA512:
6
- metadata.gz: e4a429baab0daca06475b0704696890fddb6d9782472518ce185286f469cefb0e99812d39a1f60fd2a6eab14d5887ea484a9ae914aa7026491c60969900af251
7
- data.tar.gz: c70a49573fe976d295f0b8cb89d33b433cce2b57e497f8e58f62b9d50c7794c0c799a4c3737ad3bfcd3039adc003c0da39c7514e2b7dc70d9fbc6ce0e6aa570e
6
+ metadata.gz: c07eccee9534c1cb6000f9c97c8de70277808da761f6b2b81defbc48f26fa1ddc9eefd7ef92c7bd775527d3b395b6f66117c70d7ec1c9ec66db3459a717b247c
7
+ data.tar.gz: ed41b9a0c44f928f2297b7e57a404c0fc15fd771bd6cc91a0611f89926af75de04502daa61e82f306586be3ad05e5797a5c5b40db5e872961f96ac9db317382b
@@ -0,0 +1 @@
1
+ See example.rb file.
@@ -21,26 +21,34 @@ class Leafleter
21
21
  })"
22
22
  end
23
23
 
24
- def self.get_html_page_prefix(title, lat_centered, lon_centered, zlevel_centered=13, tile_layer = get_standard_OSM_tile_Layer, width_percent = 100, sidebar_content = "", css = nil)
25
- returned = """
26
- <!DOCTYPE html>
27
- <html>
28
- <head>
29
- <title>""" + title + """</title>
30
- <meta charset=\"utf-8\" />
31
- <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
24
+ def self.get_standard_prefix_of_any_html_page(title)
25
+ return "<!DOCTYPE html>
26
+ <html>
27
+ <head>
28
+ <title>" + title + "</title>
29
+ <meta charset=\"utf-8\" />
30
+ <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
31
+ end
32
+
33
+ def self.get_leaflet_dependencies
34
+ # see https://leafletjs.com/download.html for updates
35
+ '<link rel="stylesheet" href="https://unpkg.com/leaflet@1.4.0/dist/leaflet.css"
36
+ integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
37
+ crossorigin=""/>
38
+ <script src="https://unpkg.com/leaflet@1.4.0/dist/leaflet.js"
39
+ integrity="sha512-QVftwZFqvtRNi0ZyCtsznlKSWOStnDORoefr1enyq5mVL4tmKB3S/EnC3rRJcxCPavG10IcrVGSmPh6Qw5lwrg=="
40
+ crossorigin=""></script>'
41
+ end
32
42
 
33
- <link rel=\"stylesheet\" href=\"https://unpkg.com/leaflet@1.3.3/dist/leaflet.css\"
34
- integrity=\"sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==\"
35
- crossorigin=""/>
36
- <script src=\"https://unpkg.com/leaflet@1.3.3/dist/leaflet.js\"
37
- integrity=\"sha512-tAGcCfR4Sc5ZP5ZoVz0quoZDYX5aCtEm/eu1KhSLj2c9eFrylXZknQYmxUssFaVJKvvc0dJQixhGjG2yXWiV9Q==\"
38
- crossorigin=""></script>
39
- """
43
+ def self.get_html_page_prefix(title, lat_centered, lon_centered, zlevel_centered = 13, tile_layer = get_standard_OSM_tile_Layer, width_percent = 100, sidebar_content = "", css = nil)
44
+ returned = "
45
+ #{get_standard_prefix_of_any_html_page(title)}
46
+ #{get_leaflet_dependencies}
47
+ "
40
48
  unless css.nil?
41
49
  returned += '<link rel="stylesheet" type="text/css" href="' + css + '" />'
42
50
  end
43
- returned += """<style>
51
+ returned += "<style>
44
52
  body {
45
53
  padding: 0;
46
54
  margin: 0;
@@ -53,35 +61,35 @@ class Leafleter
53
61
  height: 100%;
54
62
  width: #{width_percent}%;
55
63
  float: left;
56
- }"""
64
+ }"
57
65
  if width_percent != 100
58
- returned += """
66
+ returned += "
59
67
  #pane {
60
68
  height: 100%;
61
69
  width: #{100 - width_percent}%;
62
70
  float: right;
63
- }"""
71
+ }"
64
72
  end
65
73
  returned +=
66
- """ </style>
74
+ " </style>
67
75
  </head>
68
76
  <body>
69
77
  <div id=\"map\"></div><div id=\"pane\">#{sidebar_content}</div>
70
78
 
71
79
  <script>
72
- var map = L.map('map').setView([""" + "#{lat_centered}, #{lon_centered}], #{zlevel_centered}" + """);
80
+ var map = L.map('map').setView([" + "#{lat_centered}, #{lon_centered}], #{zlevel_centered}" + ");
73
81
  mapLink = '<a href=\"http://openstreetmap.org\">OpenStreetMap</a>';
74
82
  #{tile_layer}.addTo(map);
75
- """
83
+ "
76
84
  return returned
77
85
  end
78
86
 
79
87
  def self.get_html_page_suffix
80
- return """
88
+ return "
81
89
  </script>
82
90
  </body>
83
91
  </html>
84
- """
92
+ "
85
93
  end
86
94
 
87
95
  def self.get_location(lat, lon)
@@ -93,17 +101,18 @@ class Leafleter
93
101
  return "L.marker(" + location + ").addTo(map).bindPopup(\"" + text + ".\");\n"
94
102
  end
95
103
 
96
- def self.get_circle_marker(text, lat, lon, radius = 10, options = {})
104
+ def self.get_circle_marker(text, lat, lon, radius_in_px = 10, options = {})
97
105
  location = get_location(lat, lon)
98
106
  option_string = ""
99
107
  if options != {}
100
108
  option_string = ", {"
101
- for pair in options
109
+ options.each do |pair|
102
110
  option_string += "\t#{pair[0]}: #{pair[1]},"
103
111
  end
104
112
  option_string += "\n}"
105
113
  end
106
- return "L.circleMarker(" + location + option_string + ").setRadius(#{radius}).addTo(map).bindPopup(\"" + text + ".\");\n"
114
+ # docs at https://leafletjs.com/reference-1.4.0.html#circlemarker
115
+ return "L.circleMarker(" + location + option_string + ").setRadius(#{radius_in_px}).addTo(map).bindPopup(\"" + text + ".\");\n"
107
116
  end
108
117
 
109
118
  def self.get_line(lat1, lon1, lat2, lon2, color = 'red', weight = 3, opacity = 0.7)
@@ -112,7 +121,7 @@ class Leafleter
112
121
  end
113
122
 
114
123
  def self.get_polygon(positions, color = 'red', fill_color = 'red', weight = 3, opacity = 0.7)
115
- return get_polyline(positions, color, weight, opacity)
124
+ return get_polyline(positions, color, fill_color, weight, opacity)
116
125
  end
117
126
 
118
127
  def self.get_polyline(positions, color = 'red', fill_color = 'red', weight = 3, opacity = 0.7)
@@ -121,6 +130,7 @@ class Leafleter
121
130
  locations_string += ", " if locations_string != ""
122
131
  locations_string += get_location(position[0], position[1])
123
132
  end
124
- return " L.polyline([" + locations_string + "]," + " {color: '" + color.to_s + "', fill: '" + fill_color.to_s + "', weight: " + weight.to_s + ", opacity: " + opacity.to_s + ", lineJoin: 'round'}).addTo(map);"""
133
+ styling = " {color: '" + color.to_s + "', fill: '" + fill_color.to_s + "', weight: " + weight.to_s + ", opacity: " + opacity.to_s + ", lineJoin: 'round'}"
134
+ return " L.polyline([" + locations_string + "]," + styling + ").addTo(map);"
125
135
  end
126
136
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leafleter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Konieczny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-27 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2019-04-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: matkoniecz-ruby-style
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: Generator of Leaflet maps.
14
28
  email:
15
29
  - matkoniecz@gmail.com
@@ -17,6 +31,7 @@ executables: []
17
31
  extensions: []
18
32
  extra_rdoc_files: []
19
33
  files:
34
+ - README.md
20
35
  - lib/leafleter.rb
21
36
  - license.txt
22
37
  homepage: https://github.com/matkoniecz/leafleter
@@ -39,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
54
  version: 1.8.23
40
55
  requirements: []
41
56
  rubyforge_project:
42
- rubygems_version: 2.5.2.1
57
+ rubygems_version: 2.6.14.4
43
58
  signing_key:
44
59
  specification_version: 4
45
60
  summary: Generator of Leaflet maps.