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.
- checksums.yaml +4 -4
- data/lib/leafleter.rb +88 -76
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 547aab3050fc3bdde8c4836ff7f00a0195a24605
|
4
|
+
data.tar.gz: 35d2971b4dbea57cfa0c75384cb5619072eb74e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4a429baab0daca06475b0704696890fddb6d9782472518ce185286f469cefb0e99812d39a1f60fd2a6eab14d5887ea484a9ae914aa7026491c60969900af251
|
7
|
+
data.tar.gz: c70a49573fe976d295f0b8cb89d33b433cce2b57e497f8e58f62b9d50c7794c0c799a4c3737ad3bfcd3039adc003c0da39c7514e2b7dc70d9fbc6ce0e6aa570e
|
data/lib/leafleter.rb
CHANGED
@@ -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: © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
6
|
+
end
|
2
7
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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: © <a href=\"http://cartodb.com/attributions\">CartoDB</a>',
|
11
|
+
subdomains: 'abcd',
|
12
|
+
maxZoom: 19
|
13
|
+
})"
|
14
|
+
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
22
|
+
end
|
20
23
|
|
21
|
-
|
22
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
32
|
-
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
""" </style>
|
58
|
-
</head>
|
59
|
-
<body>
|
60
|
-
|
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
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
-
|
69
|
-
|
76
|
+
return returned
|
77
|
+
end
|
70
78
|
|
71
|
-
|
72
|
-
|
79
|
+
def self.get_html_page_suffix
|
80
|
+
return """
|
73
81
|
</script>
|
74
82
|
</body>
|
75
83
|
</html>
|
76
84
|
"""
|
77
|
-
|
85
|
+
end
|
78
86
|
|
87
|
+
def self.get_location(lat, lon)
|
88
|
+
return "[" + lat.to_s + ", " + lon.to_s + "]"
|
89
|
+
end
|
79
90
|
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
85
|
-
|
86
|
-
|
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
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
-
|
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.
|
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:
|
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.
|
42
|
+
rubygems_version: 2.5.2.1
|
43
43
|
signing_key:
|
44
44
|
specification_version: 4
|
45
45
|
summary: Generator of Leaflet maps.
|