leafleter 0.0.0 → 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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/leafleter.rb +88 -76
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b03cbe67ef626dd24c049e9cfad1aa104ad8ebb
4
- data.tar.gz: be363cd657abf48cc6128946afd2706a036269ae
3
+ metadata.gz: 547aab3050fc3bdde8c4836ff7f00a0195a24605
4
+ data.tar.gz: 35d2971b4dbea57cfa0c75384cb5619072eb74e0
5
5
  SHA512:
6
- metadata.gz: ae2aa65b42b53acaef185f38cbe3867edd081d1d09f465d4083d3ec19f2ed7a2c904ef6b26135ba9293f2bfce077000e9c3f9c582480b7e744d0e136977640b7
7
- data.tar.gz: 3e5e5c9d49061d247013f5e2ad688dac21ad37cc731b16f323e01262d287e53ba7cee5ceb620e975af090efe9347c0ac00c2d5285851e042f4f3305991c16bbd
6
+ metadata.gz: e4a429baab0daca06475b0704696890fddb6d9782472518ce185286f469cefb0e99812d39a1f60fd2a6eab14d5887ea484a9ae914aa7026491c60969900af251
7
+ data.tar.gz: c70a49573fe976d295f0b8cb89d33b433cce2b57e497f8e58f62b9d50c7794c0c799a4c3737ad3bfcd3039adc003c0da39c7514e2b7dc70d9fbc6ce0e6aa570e
@@ -1,35 +1,44 @@
1
1
  class Leafleter
2
+ # consider importing more from http://leaflet-extras.github.io/leaflet-providers/preview/
3
+ # or using this extension
4
+ def self.openstreetmap_copyright_notice
5
+ 'data: &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
6
+ end
2
7
 
3
- #consider importing more from http://leaflet-extras.github.io/leaflet-providers/preview/
4
- #or using this extension
5
- def self.get_positron_tile_Layer()
6
- return "L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
7
- attribution: '&copy; <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a> &copy; <a href=\"http://cartodb.com/attributions\">CartoDB</a>',
8
- subdomains: 'abcd',
9
- maxZoom: 19
10
- })"
11
- end
12
-
8
+ def self.get_positron_tile_Layer
9
+ return "L.tileLayer('https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png', {
10
+ attribution: '#{openstreetmap_copyright_notice}, basemap: &copy; <a href=\"http://cartodb.com/attributions\">CartoDB</a>',
11
+ subdomains: 'abcd',
12
+ maxZoom: 19
13
+ })"
14
+ end
13
15
 
14
- def self.get_standard_OSM_tile_Layer()
15
- return "L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
16
- maxZoom: 19,
17
- attribution: '&copy; <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>'
16
+ def self.get_standard_OSM_tile_Layer
17
+ return "L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
18
+ attribution: '#{openstreetmap_copyright_notice}, basemap made by <a href=\"https://github.com/gravitystorm/openstreetmap-carto/\">openstreetmap-carto project</a>',
19
+ subdomains: 'abc',
20
+ maxZoom: 19
18
21
  })"
19
- end
22
+ end
20
23
 
21
- def self.get_before(title, lat_centered, lon_centered, zlevel_centered, tile_layer=get_standard_OSM_tile_Layer(), width_percent=100, sidebar_content="", css=nil)
22
- returned = """
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 = """
23
26
  <!DOCTYPE html>
24
27
  <html>
25
28
  <head>
26
- <title>""" + title + """</title>
27
- <meta charset=\"utf-8\" />
28
- <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
29
- <link rel=\"stylesheet\" href=\"http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css\" />
29
+ <title>""" + title + """</title>
30
+ <meta charset=\"utf-8\" />
31
+ <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
32
+
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>
30
39
  """
31
- if css != nil
32
- returned += '<link rel="stylesheet" type="text/css" href="' + css + '" />'
40
+ unless css.nil?
41
+ returned += '<link rel="stylesheet" type="text/css" href="' + css + '" />'
33
42
  end
34
43
  returned += """<style>
35
44
  body {
@@ -45,70 +54,73 @@ class Leafleter
45
54
  width: #{width_percent}%;
46
55
  float: left;
47
56
  }"""
48
- if width_percent != 100
49
- returned+= """
50
- #pane {
51
- height: 100%;
52
- width: #{100-width_percent}%;
53
- float: right;
54
- }"""
55
- end
56
- returned +=
57
- """ </style>
58
- </head>
59
- <body>
60
- <div id=\"map\"></div><div id=\"pane\">#{sidebar_content}</div>
57
+ if width_percent != 100
58
+ returned += """
59
+ #pane {
60
+ height: 100%;
61
+ width: #{100 - width_percent}%;
62
+ float: right;
63
+ }"""
64
+ end
65
+ returned +=
66
+ """ </style>
67
+ </head>
68
+ <body>
69
+ <div id=\"map\"></div><div id=\"pane\">#{sidebar_content}</div>
61
70
 
62
- <script src=\"http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js\"></script>
63
- <script>
64
- var map = L.map('map').setView([""" + "#{lat_centered}, #{lon_centered}], #{zlevel_centered}" + """);
65
- mapLink = '<a href=\"http://openstreetmap.org\">OpenStreetMap</a>';
66
- #{tile_layer}.addTo(map);
71
+ <script>
72
+ var map = L.map('map').setView([""" + "#{lat_centered}, #{lon_centered}], #{zlevel_centered}" + """);
73
+ mapLink = '<a href=\"http://openstreetmap.org\">OpenStreetMap</a>';
74
+ #{tile_layer}.addTo(map);
67
75
  """
68
- return returned
69
- end
76
+ return returned
77
+ end
70
78
 
71
- def self.get_after()
72
- return """
79
+ def self.get_html_page_suffix
80
+ return """
73
81
  </script>
74
82
  </body>
75
83
  </html>
76
84
  """
77
- end
85
+ end
78
86
 
87
+ def self.get_location(lat, lon)
88
+ return "[" + lat.to_s + ", " + lon.to_s + "]"
89
+ end
79
90
 
80
- def self.get_location(lat, lon)
81
- return "[" + lat.to_s + ", " + lon.to_s + "]"
82
- end
91
+ def self.get_marker(text, lat, lon)
92
+ location = get_location(lat, lon)
93
+ return "L.marker(" + location + ").addTo(map).bindPopup(\"" + text + ".\");\n"
94
+ end
83
95
 
84
- def self.get_marker(text, lat, lon)
85
- location = get_location(lat, lon)
86
- return "L.marker(" + location + ").addTo(map).bindPopup(\"" + text + ".\");\n"
96
+ def self.get_circle_marker(text, lat, lon, radius = 10, options = {})
97
+ location = get_location(lat, lon)
98
+ option_string = ""
99
+ if options != {}
100
+ option_string = ", {"
101
+ for pair in options
102
+ option_string += "\t#{pair[0]}: #{pair[1]},"
103
+ end
104
+ option_string += "\n}"
87
105
  end
106
+ return "L.circleMarker(" + location + option_string + ").setRadius(#{radius}).addTo(map).bindPopup(\"" + text + ".\");\n"
107
+ end
88
108
 
89
- def self.get_circle_marker(text, lat, lon, radius=10, options={})
90
- location = get_location(lat, lon)
91
- option_string = ""
92
- if options != {}
93
- option_string = ", {"
94
- for pair in options
95
- option_string += "\t#{pair[0]}: #{pair[1]},"
96
- end
97
- option_string += "\n}"
98
- end
99
- return "L.circleMarker(" + location + option_string + ").setRadius(#{radius}).addTo(map).bindPopup(\"" + text + ".\");\n"
100
- end
109
+ def self.get_line(lat1, lon1, lat2, lon2, color = 'red', weight = 3, opacity = 0.7)
110
+ dummy_color = "black"
111
+ return get_polyline([[lat1, lon1], [lat2, lon2]], color, dummy_color, weight, opacity)
112
+ end
113
+
114
+ def self.get_polygon(positions, color = 'red', fill_color = 'red', weight = 3, opacity = 0.7)
115
+ return get_polyline(positions, color, weight, opacity)
116
+ end
101
117
 
102
- def self.get_line(lat1, lon1, lat2, lon2, color='red', weight=3, opacity=0.7)
103
- location1 = get_location(lat1, lon1)
104
- location2 = get_location(lat2, lon2)
105
- return "L.polyline([" + location1 + ", " + location2 + "]," + """
106
- {
107
- color: '""" + "#{color}" + """',
108
- weight: """ + "#{weight}" +""",
109
- opacity: """ + "#{opacity}" +""",
110
- lineJoin: 'round'
111
- }
112
- ).addTo(map);"""
118
+ def self.get_polyline(positions, color = 'red', fill_color = 'red', weight = 3, opacity = 0.7)
119
+ locations_string = ""
120
+ positions.each do |position|
121
+ locations_string += ", " if locations_string != ""
122
+ locations_string += get_location(position[0], position[1])
113
123
  end
114
- 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);"""
125
+ end
126
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leafleter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Konieczny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-05 00:00:00.000000000 Z
11
+ date: 2018-07-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Generator of Leaflet maps.
14
14
  email:
@@ -39,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  version: 1.8.23
40
40
  requirements: []
41
41
  rubyforge_project:
42
- rubygems_version: 2.6.4
42
+ rubygems_version: 2.5.2.1
43
43
  signing_key:
44
44
  specification_version: 4
45
45
  summary: Generator of Leaflet maps.