leafleter 0.0.0
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 +7 -0
- data/lib/leafleter.rb +114 -0
- data/license.txt +9 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7b03cbe67ef626dd24c049e9cfad1aa104ad8ebb
|
4
|
+
data.tar.gz: be363cd657abf48cc6128946afd2706a036269ae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ae2aa65b42b53acaef185f38cbe3867edd081d1d09f465d4083d3ec19f2ed7a2c904ef6b26135ba9293f2bfce077000e9c3f9c582480b7e744d0e136977640b7
|
7
|
+
data.tar.gz: 3e5e5c9d49061d247013f5e2ad688dac21ad37cc731b16f323e01262d287e53ba7cee5ceb620e975af090efe9347c0ac00c2d5285851e042f4f3305991c16bbd
|
data/lib/leafleter.rb
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
class Leafleter
|
2
|
+
|
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: '© <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a> © <a href=\"http://cartodb.com/attributions\">CartoDB</a>',
|
8
|
+
subdomains: 'abcd',
|
9
|
+
maxZoom: 19
|
10
|
+
})"
|
11
|
+
end
|
12
|
+
|
13
|
+
|
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: '© <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>'
|
18
|
+
})"
|
19
|
+
end
|
20
|
+
|
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 = """
|
23
|
+
<!DOCTYPE html>
|
24
|
+
<html>
|
25
|
+
<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\" />
|
30
|
+
"""
|
31
|
+
if css != nil
|
32
|
+
returned += '<link rel="stylesheet" type="text/css" href="' + css + '" />'
|
33
|
+
end
|
34
|
+
returned += """<style>
|
35
|
+
body {
|
36
|
+
padding: 0;
|
37
|
+
margin: 0;
|
38
|
+
}
|
39
|
+
html, body {
|
40
|
+
height: 100%;
|
41
|
+
width: 100%;
|
42
|
+
}
|
43
|
+
#map {
|
44
|
+
height: 100%;
|
45
|
+
width: #{width_percent}%;
|
46
|
+
float: left;
|
47
|
+
}"""
|
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>
|
61
|
+
|
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);
|
67
|
+
"""
|
68
|
+
return returned
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.get_after()
|
72
|
+
return """
|
73
|
+
</script>
|
74
|
+
</body>
|
75
|
+
</html>
|
76
|
+
"""
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
def self.get_location(lat, lon)
|
81
|
+
return "[" + lat.to_s + ", " + lon.to_s + "]"
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.get_marker(text, lat, lon)
|
85
|
+
location = get_location(lat, lon)
|
86
|
+
return "L.marker(" + location + ").addTo(map).bindPopup(\"" + text + ".\");\n"
|
87
|
+
end
|
88
|
+
|
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
|
101
|
+
|
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);"""
|
113
|
+
end
|
114
|
+
end
|
data/license.txt
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
This software and associated documentation files (the "Software") is
|
2
|
+
released under the CC0 Public Domain Dedication, version 1.0, as
|
3
|
+
published by Creative Commons. To the extent possible under law, the
|
4
|
+
author(s) have dedicated all copyright and related and neighboring
|
5
|
+
rights to the Software to the public domain worldwide. The Software is
|
6
|
+
distributed WITHOUT ANY WARRANTY.
|
7
|
+
If you did not receive a copy of the CC0 Public Domain Dedication
|
8
|
+
along with the Software, see
|
9
|
+
<http://creativecommons.org/publicdomain/zero/1.0/>
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: leafleter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mateusz Konieczny
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Generator of Leaflet maps.
|
14
|
+
email:
|
15
|
+
- matkoniecz@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/leafleter.rb
|
21
|
+
- license.txt
|
22
|
+
homepage: https://github.com/matkoniecz/leafleter
|
23
|
+
licenses:
|
24
|
+
- CC0
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 1.8.23
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.6.4
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Generator of Leaflet maps.
|
46
|
+
test_files: []
|