leafleter 0.0.4 → 0.0.7
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 +5 -5
- data/README.md +7 -1
- data/lib/leafleter.rb +69 -30
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8a36de1979673f6c4480dd3494a1046d412016d13807ec05c3053f717c83a3c5
|
4
|
+
data.tar.gz: df53ae0bdf01cb1d8ace1fae8092ccc3dadfec0853140ef266024db9806ccc49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c71130596378c78afd457c8921bf3eb8f6fea8a972be186eb3e964274f6c2e3b7c73f8b971e8f33b8395d302bb1a85dce32501b5224efd9889a498138a7fae2
|
7
|
+
data.tar.gz: 7aff81bfd3ef7e8e8ddff3b0ceb1b90759b5c0d5c0aa97ccf8ba0835d6b1797efba12c93754048e3a1b0e8980d4a8a21042dde3197e78b4eb394ad7444543727
|
data/README.md
CHANGED
data/lib/leafleter.rb
CHANGED
@@ -2,21 +2,32 @@ 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: © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
5
|
+
return 'data: © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.
|
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: © <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.
|
17
|
-
return "L.tileLayer('http://
|
28
|
+
def self.get_standard_OSM_tile_layer
|
29
|
+
return "L.tileLayer('http://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
|
-
subdomains: 'abc',
|
20
31
|
maxZoom: 19
|
21
32
|
})"
|
22
33
|
end
|
@@ -40,7 +51,52 @@ class Leafleter
|
|
40
51
|
crossorigin=""></script>'
|
41
52
|
end
|
42
53
|
|
43
|
-
def self.
|
54
|
+
def self.map_area_part_of_styling(width_percent)
|
55
|
+
return " body {
|
56
|
+
padding: 0;
|
57
|
+
margin: 0;
|
58
|
+
}
|
59
|
+
html, body {
|
60
|
+
height: 100%;
|
61
|
+
width: 100%;
|
62
|
+
}
|
63
|
+
#map {
|
64
|
+
height: 100%;
|
65
|
+
width: #{width_percent}%;
|
66
|
+
float: left;
|
67
|
+
}"
|
68
|
+
if width_percent != 100
|
69
|
+
returned += "
|
70
|
+
#pane {
|
71
|
+
height: 100%;
|
72
|
+
width: #{100 - width_percent}%;
|
73
|
+
float: right;
|
74
|
+
}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.internal_leaflet_styling_part()
|
79
|
+
# workaround for https://github.com/Leaflet/Leaflet/issues/4686
|
80
|
+
return "\n .leaflet-fade-anim .leaflet-tile,.leaflet-zoom-anim .leaflet-zoom-animated { will-change:auto !important; }"
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.recoloured_markers_styling()
|
84
|
+
return ""\
|
85
|
+
"img.huechange_pinkish_marker { filter: hue-rotate(120deg); }"\
|
86
|
+
"img.huechange_green_marker { filter: hue-rotate(240deg); }"\
|
87
|
+
end
|
88
|
+
|
89
|
+
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)
|
90
|
+
# asserts for parameters, I wasted over 1 hour on bug that would be caught by this
|
91
|
+
zlevel_centered.to_f
|
92
|
+
lat_centered.to_f
|
93
|
+
lon_centered.to_f
|
94
|
+
width_percent.to_f
|
95
|
+
raise if width_percent > 100
|
96
|
+
raise if width_percent <= 0
|
97
|
+
raise if zlevel_centered <= 0
|
98
|
+
######
|
99
|
+
|
44
100
|
returned = "
|
45
101
|
#{get_standard_prefix_of_any_html_page(title)}
|
46
102
|
#{get_leaflet_dependencies}
|
@@ -48,30 +104,12 @@ class Leafleter
|
|
48
104
|
unless css.nil?
|
49
105
|
returned += '<link rel="stylesheet" type="text/css" href="' + css + '" />'
|
50
106
|
end
|
51
|
-
returned += "<style
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
107
|
+
returned += "<style>\n"
|
108
|
+
returned += self.map_area_part_of_styling(width_percent)
|
109
|
+
returned += self.internal_leaflet_styling_part()
|
110
|
+
returned += self.recoloured_markers_styling()
|
73
111
|
returned +=
|
74
|
-
" </style>
|
112
|
+
"\n </style>
|
75
113
|
</head>
|
76
114
|
<body>
|
77
115
|
<div id=\"map\"></div><div id=\"pane\">#{sidebar_content}</div>
|
@@ -97,6 +135,7 @@ class Leafleter
|
|
97
135
|
end
|
98
136
|
|
99
137
|
def self.get_marker(text, lat, lon)
|
138
|
+
# TODO: implement what is implemented for Python variant
|
100
139
|
location = get_location(lat, lon)
|
101
140
|
return "L.marker(" + location + ").addTo(map).bindPopup(\"" + text + ".\");\n"
|
102
141
|
end
|
@@ -131,6 +170,6 @@ class Leafleter
|
|
131
170
|
locations_string += get_location(position[0], position[1])
|
132
171
|
end
|
133
172
|
styling = " {color: '" + color.to_s + "', fill: '" + fill_color.to_s + "', weight: " + weight.to_s + ", opacity: " + opacity.to_s + ", lineJoin: 'round'}"
|
134
|
-
return "
|
173
|
+
return "L.polyline([" + locations_string + "]," + styling + ").addTo(map);\n"
|
135
174
|
end
|
136
175
|
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.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateusz Konieczny
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: matkoniecz-ruby-style
|
@@ -34,11 +34,11 @@ files:
|
|
34
34
|
- README.md
|
35
35
|
- lib/leafleter.rb
|
36
36
|
- license.txt
|
37
|
-
homepage: https://github.com/matkoniecz/
|
37
|
+
homepage: https://github.com/matkoniecz/leafleter_ruby
|
38
38
|
licenses:
|
39
39
|
- CC0
|
40
40
|
metadata: {}
|
41
|
-
post_install_message:
|
41
|
+
post_install_message:
|
42
42
|
rdoc_options: []
|
43
43
|
require_paths:
|
44
44
|
- lib
|
@@ -53,9 +53,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.8.23
|
55
55
|
requirements: []
|
56
|
-
|
57
|
-
|
58
|
-
signing_key:
|
56
|
+
rubygems_version: 3.4.20
|
57
|
+
signing_key:
|
59
58
|
specification_version: 4
|
60
59
|
summary: Generator of Leaflet maps.
|
61
60
|
test_files: []
|