leafleter 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +5 -5
  2. data/lib/leafleter.rb +59 -27
  3. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a9c6d60b6b959f1ab7ab8be9c9f6e3adbfca92bb
4
- data.tar.gz: 972f1b767052555e2eb225a06f005ac2120c7e23
2
+ SHA256:
3
+ metadata.gz: e09918bea7239e6340a66c76179c7dfd1d34b2fceac52e5a3f3640280c88d31a
4
+ data.tar.gz: fb5feca876bcaa68919ffc68543b2036ff3ee01ca2275d94b963f72e02761729
5
5
  SHA512:
6
- metadata.gz: c07eccee9534c1cb6000f9c97c8de70277808da761f6b2b81defbc48f26fa1ddc9eefd7ef92c7bd775527d3b395b6f66117c70d7ec1c9ec66db3459a717b247c
7
- data.tar.gz: ed41b9a0c44f928f2297b7e57a404c0fc15fd771bd6cc91a0611f89926af75de04502daa61e82f306586be3ad05e5797a5c5b40db5e872961f96ac9db317382b
6
+ metadata.gz: 0a3edea1d98195a21e0e810e14a1935e44ba0f0ea77dfc38fdaabcd23e10b3692b40cb4bec511a97ee022ef2e9545fe8547a1be09b1ba34b9e1d896e0fc249bf
7
+ data.tar.gz: d9319111b748a6562c4f70f1298929b6c52f0993978c7567372c746361f7708b012a0d9a0cd38fb3e6defd5ef2c4f93e92f6f432ac9a0001abe9ad3606496d5f
@@ -2,18 +2,30 @@ class Leafleter
2
2
  # consider importing more from http://leaflet-extras.github.io/leaflet-providers/preview/
3
3
  # or using this extension
4
4
  def self.openstreetmap_copyright_notice
5
- 'data: &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
5
+ return 'data: &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
6
6
  end
7
7
 
8
- def self.get_positron_tile_Layer
8
+ def self.get_grayscale_tile_layer
9
+ return self.get_positron_tile_layer
10
+ end
11
+
12
+ def self.get_positron_tile_layer
9
13
  return "L.tileLayer('https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png', {
10
14
  attribution: '#{openstreetmap_copyright_notice}, basemap: &copy; <a href=\"http://cartodb.com/attributions\">CartoDB</a>',
11
15
  subdomains: 'abcd',
12
16
  maxZoom: 19
13
17
  })"
18
+ end
19
+
20
+ def self.get_gray_transformed_osm_carto_tile_layer
21
+ return "L.tileLayer('https://tiles.wmflabs.org/bw-mapnik/${z}/${x}/${y}.png', {
22
+ attribution: '#{openstreetmap_copyright_notice}',
23
+ subdomains: 'abcd',
24
+ maxZoom: 19
25
+ })"
14
26
  end
15
27
 
16
- def self.get_standard_OSM_tile_Layer
28
+ def self.get_standard_OSM_tile_layer
17
29
  return "L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
18
30
  attribution: '#{openstreetmap_copyright_notice}, basemap made by <a href=\"https://github.com/gravitystorm/openstreetmap-carto/\">openstreetmap-carto project</a>',
19
31
  subdomains: 'abc',
@@ -40,7 +52,46 @@ class Leafleter
40
52
  crossorigin=""></script>'
41
53
  end
42
54
 
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)
55
+ def self.map_area_part_of_styling(width_percent)
56
+ return " body {
57
+ padding: 0;
58
+ margin: 0;
59
+ }
60
+ html, body {
61
+ height: 100%;
62
+ width: 100%;
63
+ }
64
+ #map {
65
+ height: 100%;
66
+ width: #{width_percent}%;
67
+ float: left;
68
+ }"
69
+ if width_percent != 100
70
+ returned += "
71
+ #pane {
72
+ height: 100%;
73
+ width: #{100 - width_percent}%;
74
+ float: right;
75
+ }"
76
+ end
77
+ end
78
+
79
+ def self.internal_leaflet_styling_part()
80
+ # workaround for https://github.com/Leaflet/Leaflet/issues/4686
81
+ return "\n .leaflet-fade-anim .leaflet-tile,.leaflet-zoom-anim .leaflet-zoom-animated { will-change:auto !important; }"
82
+ end
83
+
84
+ 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)
85
+ # asserts for parameters, I wasted over 1 hour on bug that would be caught by this
86
+ zlevel_centered.to_f
87
+ lat_centered.to_f
88
+ lon_centered.to_f
89
+ width_percent.to_f
90
+ raise if width_percent > 100
91
+ raise if width_percent < 100
92
+ raise if zlevel_centered <= 0
93
+ ######
94
+
44
95
  returned = "
45
96
  #{get_standard_prefix_of_any_html_page(title)}
46
97
  #{get_leaflet_dependencies}
@@ -48,30 +99,11 @@ class Leafleter
48
99
  unless css.nil?
49
100
  returned += '<link rel="stylesheet" type="text/css" href="' + css + '" />'
50
101
  end
51
- returned += "<style>
52
- body {
53
- padding: 0;
54
- margin: 0;
55
- }
56
- html, body {
57
- height: 100%;
58
- width: 100%;
59
- }
60
- #map {
61
- height: 100%;
62
- width: #{width_percent}%;
63
- float: left;
64
- }"
65
- if width_percent != 100
66
- returned += "
67
- #pane {
68
- height: 100%;
69
- width: #{100 - width_percent}%;
70
- float: right;
71
- }"
72
- end
102
+ returned += "<style>"
103
+ returned += self.map_area_part_of_styling(width_percent)
104
+ returned += self.internal_leaflet_styling_part()
73
105
  returned +=
74
- " </style>
106
+ "\n </style>
75
107
  </head>
76
108
  <body>
77
109
  <div id=\"map\"></div><div id=\"pane\">#{sidebar_content}</div>
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.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Konieczny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-27 00:00:00.000000000 Z
11
+ date: 2020-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: matkoniecz-ruby-style
@@ -53,8 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.8.23
55
55
  requirements: []
56
- rubyforge_project:
57
- rubygems_version: 2.6.14.4
56
+ rubygems_version: 3.1.2
58
57
  signing_key:
59
58
  specification_version: 4
60
59
  summary: Generator of Leaflet maps.