volt-osmaps 0.1.0 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a0baf9a2e519bc3247e2dd63b4f6f9503982eec
4
- data.tar.gz: f49eea4e5e57d9b0ea77c5774778f56d56d020b8
3
+ metadata.gz: 5172d71483306b4b43330eae6db44286c051221a
4
+ data.tar.gz: 303016bdb6da60edd5be61f484a6924f8979d3da
5
5
  SHA512:
6
- metadata.gz: 3d7f873ed427817d5d544ebee919cb6c115f3e0a7a2fc9950903ecfc0f8f1cb86b4a0d9b3f7c8eeb3a8aa00054feaf5b4e2fcdc833bd5684fa838549f55b71a7
7
- data.tar.gz: 0e3d81f40a3e78a99e925421d4e0db98c7442498f1467aa9af521f211e8cae47f7ac7a66514cb8d46b46dbf52a98e58b211872f33df3899b26434fb0b73b215e
6
+ metadata.gz: 78a4e37ab30534bbc3b74e84a7e8bb8931cea53778875b2ac1948dbad38363941e6b64a8a206c96b65fe937b427f2649a4a9a59026d5cf3569eb6a92e3a7ddd1
7
+ data.tar.gz: cd58a559f1ba0f2b6fac19adead8667253a607a9ea79eb1d0f69ddb51c3512bb3939e9847d820428c3edfc6fcb11a7c2f14d328db6a124e2b20beb17f2ce3669
data/README.md CHANGED
@@ -18,13 +18,33 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ ### Map
22
+
21
23
  Typical Usage to add a map with a marker:
22
24
 
23
- <:osmaps height="380px" latitude="{{ latitude }}" longitude="{{ longitude }}" title="{{ title }}" />
25
+ <:osmaps height="380px" latitude="{{ latitude }}" longitude="{{ longitude }}" />
26
+
27
+ Options
28
+ * title to show a marker at the center of the map. On click, a popup will show title
29
+ * zoom is a numeric option. Default is 15
30
+
31
+ With the option title given, it will show a map as such:
32
+
33
+ ![Example map](https://github.com/heri/volt-osmaps/blob/master/app/osmaps/example.jpg?raw=true)
34
+
35
+ You will need a geocoder if you only have a street address instead of the latitude, longitude coordinates.
36
+
37
+ ### Adding a marker
38
+
39
+ After you have set a <:osmaps />, you can add markers and polygons:
40
+
41
+ <:osmaps:marker latitude="{{ latitude }}" longitude="{{ longitude }}" title="{{ title }}"/>
42
+
43
+ ### Polygon
24
44
 
25
- A marker will be added in the center that will open a popup with the "title" as information
45
+ An array of lat,long coordinates will draw a polygon layer on the map. For example:
26
46
 
27
- You will need a geocoder if you only have a street address instead of the latitude, longitude coordinates
47
+ <:osmaps:polygon LatLongArray="[[51.509, -0.08],[51.503, -0.06],[51.51, -0.047]]" />
28
48
 
29
49
  ## Contributing
30
50
 
@@ -3,10 +3,14 @@ module Osmaps
3
3
  def index
4
4
  end
5
5
 
6
- def map(latitude, longitude, title)
6
+ def map(latitude, longitude, opts = {})
7
7
  `var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib});`
8
+ zoom = opts[:zoom] || 15
8
9
  `var map = L.map('osmaps').setView([latitude, longitude], 15).addLayer(osm);`
9
- `L.marker([ latitude, longitude]).addTo(map).bindPopup(title);`
10
+ if opts[:title]
11
+ `L.marker([ latitude, longitude]).addTo(map).bindPopup(title);`
12
+ end
13
+ `L.control.scale( {imperial: false} )`
10
14
  return nil
11
15
  end
12
16
 
@@ -0,0 +1,12 @@
1
+ module Osmaps
2
+ class MarkerController < Volt::ModelController
3
+ def index
4
+ end
5
+
6
+ def marker(latitude, longitude, title, opts = {})
7
+ `L.marker([ latitude, longitude]).addTo(map).bindPopup(title);`
8
+ return nil
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Osmaps
2
+ class PolygonController < Volt::ModelController
3
+ def index
4
+ end
5
+
6
+ def polygon(LatLongArray, opts = {})
7
+ `L.polygon(LatLongArray).addTo(map);`
8
+ return nil
9
+ end
10
+
11
+ end
12
+ end
Binary file
@@ -2,4 +2,4 @@
2
2
 
3
3
  <div id="osmaps" class="osmaps" style="height: {{ attrs.height }};">&nbsp;</div>
4
4
 
5
- {{ map(attrs.latitude, attrs.longitude, attrs.title) }}
5
+ {{ map(attrs.latitude, attrs.longitude, {title: attrs.title, zoom: attrs.zoom}) }}
@@ -0,0 +1,3 @@
1
+ <:Body>
2
+
3
+ {{ marker(attrs.latitude, attrs.longitude, attrs.title ) }}
@@ -0,0 +1,3 @@
1
+ <:Body>
2
+
3
+ {{ polygon(attrs.LatLongArray) }}
@@ -1,5 +1,5 @@
1
1
  module Volt
2
2
  module Osmaps
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volt-osmaps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - heri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-19 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: volt
@@ -218,7 +218,12 @@ files:
218
218
  - app/osmaps/config/initializers/boot.rb
219
219
  - app/osmaps/config/routes.rb
220
220
  - app/osmaps/controllers/main_controller.rb
221
+ - app/osmaps/controllers/marker_controller.rb
222
+ - app/osmaps/controllers/polygon_controller.rb
223
+ - app/osmaps/example.jpg
221
224
  - app/osmaps/views/main/index.html
225
+ - app/osmaps/views/marker/index.html
226
+ - app/osmaps/views/polygon/index.html
222
227
  - lib/volt/osmaps.rb
223
228
  - lib/volt/osmaps/version.rb
224
229
  - spec/dummy/.gitignore