travlrmap 0.0.9 → 0.0.10

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.
@@ -18,6 +18,10 @@ module Travlrmap
18
18
  include Rack::Utils
19
19
 
20
20
  alias_method :h, :escape_html
21
+
22
+ def base_url
23
+ @base_url ||= "#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}"
24
+ end
21
25
  end
22
26
 
23
27
  def kml_style_url(type)
@@ -68,7 +72,7 @@ module Travlrmap
68
72
 
69
73
  f.features << KML::Placemark.new(
70
74
  :name => point[:title],
71
- :description => point[:comment],
75
+ :description => erb(:"_point_comment", :layout => false, :locals => {:point => point}),
72
76
  :geometry => KML::Point.new(:coordinates => {:lat => point[:lat], :lng => point[:lon]}),
73
77
  :style_url => "#%s" % kml_style_url(point[:type])
74
78
  )
@@ -1,3 +1,3 @@
1
1
  module Travlmap
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
data/views/_map_js.erb CHANGED
@@ -1,30 +1,24 @@
1
1
  <script type="text/javascript">
2
- $(document).ready(function(){
3
- var map = new GMaps({
4
- el: '#main_map',
5
- lat: <%= @map_view[:lat] %>,
6
- lng: <%= @map_view[:lon] %>,
7
- zoom: <%= @map_view[:zoom] %>,
8
- zoomControl : <%= @zoom_control %>,
9
- mapTypeControl : <%= @map_type_control %>,
10
- streetViewControl : <%= @street_view_control %>,
11
- overviewMapControl : <%= @overview_control %>,
12
- panControl : <%= @pan_control %>,
13
- zoomControlOpt: {
14
- style : 'DEFAULT',
15
- position: 'TOP_LEFT'
16
- },
2
+ var map;
3
+ $(document).ready(function(){
4
+ infoWindow = new google.maps.InfoWindow({});
5
+ map = new GMaps({
6
+ div: '#main_map',
7
+ zoom: <%= @map_view[:zoom] %>,
8
+ lat: <%= @map_view[:lat] %>,
9
+ lng: <%= @map_view[:lon] %>,
10
+ });
11
+ map.loadFromKML({
12
+ url: '<%= base_url %>/kml?t=<%= Time.now.to_i %>',
13
+ suppressInfoWindows: true,
14
+ preserveViewport: true,
15
+ events: {
16
+ click: function(point){
17
+ infoWindow.setContent(point.featureData.infoWindowHtml);
18
+ infoWindow.setPosition(point.latLng);
19
+ infoWindow.open(map.map);
20
+ }
21
+ }
22
+ });
17
23
  });
18
- <% @points.each do |point| %>
19
- map.addMarker({
20
- lat: <%= point[:lat] %>,
21
- lng: <%= point[:lon] %>,
22
- title: "<%= h point[:title] %>",
23
- icon: "<%= @types[ point[:type] ][:icon] %>",
24
- infoWindow: {
25
- content: <%= erb :"_point_comment", :layout => false, :locals => {:point => point} %>
26
- }
27
- });
28
- <% end %>
29
- });
30
24
  </script>
@@ -1,15 +1,15 @@
1
- "<p><h4><%= h point[:title] %></h3> \
1
+ <p>
2
2
  <% if point[:href] && point[:linkimg] %>
3
3
  <% if point[:comment] %>
4
- <%= h point[:comment] %><br /><br /> \
4
+ <%= h point[:comment] %><br /><br />
5
5
  <% end %>
6
- <a href='<%= point[:href] %>' target='_blank'><img src='<%= point[:linkimg] %>'></a> \
6
+ <a href='<%= point[:href] %>' target='_blank'><img src='<%= point[:linkimg] %>'></a>
7
7
  <% elsif point[:href] && point[:linktext] %>
8
8
  <% if point[:comment] %>
9
- <%= h point[:comment] %><br /><br /> \
9
+ <%= h point[:comment] %><br /><br />
10
10
  <% end %>
11
- <a href='<%= point[:href] %>' target='_blank'><%= point[:linktext] %></a> \
11
+ <a href='<%= point[:href] %>' target='_blank'><%= point[:linktext] %></a>
12
12
  <% elsif point[:comment] %>
13
- <%= h point[:comment] %> \
13
+ <%= h point[:comment] %>
14
14
  <% end %>
15
- </p>"
15
+ </p>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travlrmap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 9
10
- version: 0.0.9
9
+ - 10
10
+ version: 0.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - R.I.Pienaar