Module: Ovimap::Generators::Helpers

Included in:
BuildGenerator, DisplayGenerator, HeatmapGenerator, InstallGenerator, PinGenerator
Defined in:
lib/generators/ovimap/helpers.rb

Instance Method Summary collapse

Instance Method Details

#asset_pathObject



5
6
7
# File 'lib/generators/ovimap/helpers.rb', line 5

def asset_path
  "app/assets"
end

#content_forObject



29
30
31
32
33
34
35
36
37
# File 'lib/generators/ovimap/helpers.rb', line 29

def content_for
  <<-eos.gsub /^\s+/, ""
    <% content_for :map do %>
    <%= javascript_include_tag 'map.js' %>
    <% end %>
    
    <div id="mapContainer"></div>
  eos
end

#heatmap_optionsObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/generators/ovimap/helpers.rb', line 47

def heatmap_options
  <<-eof.gsub /^\s+/, ""
  
  var colorizeAPI = {
  stops: {
  "0": "#CCFF00",
  "0.5": "#FF9900",
  "1": "#CC0000"
  },
  interpolate: true
  };	

  var heatmapProvider = new nokia.maps.heatmap.Overlay({
  label: 'My Map',
  description: 'Generated with EasyMap',
  max: 20, 
  opacity: 0.9, 
  type: "value", 
  coarseness: 10,
  colors: colorizeAPI,
  });

  heatmapProvider.addData(data);
  map.overlays.add(heatmapProvider);
  eof
end

#js_pathObject



9
10
11
# File 'lib/generators/ovimap/helpers.rb', line 9

def js_path
  "#{asset_path}/javascripts"
end

#layoutsObject



17
18
19
# File 'lib/generators/ovimap/helpers.rb', line 17

def layouts
  "app/views/layouts"
end

#map_selectObject



39
40
41
# File 'lib/generators/ovimap/helpers.rb', line 39

def map_select
  "\nmap.set(\"baseMapType\", nokia.maps.map.Display.#{map_type.upcase});\n"
end

#map_styleObject



21
22
23
# File 'lib/generators/ovimap/helpers.rb', line 21

def map_style
  "\n#mapContainer {\nwidth: 100%; \nheight: 100%; \nleft: 0; \ntop: 0; \nposition: absolute;\n}\n"
end

#map_swapObject



43
44
45
# File 'lib/generators/ovimap/helpers.rb', line 43

def map_swap
  "map.set(\"baseMapType\", nokia.maps.map.Display.#{map_type.upcase});"
end

#nokia_scriptObject



25
26
27
# File 'lib/generators/ovimap/helpers.rb', line 25

def nokia_script
  "\n<script type=\"text/javascript\" charset=\"UTF-8\" src=\"http://api.maps.nokia.com/2.2.0/jsl.js?with=all\"></script>\n"
end

#pin_optionsObject



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/generators/ovimap/helpers.rb', line 74

def pin_options
  <<-eof.gsub /^\s+/, ""
  
  pindata = _.zip(_.pluck(data, "latitude"), _.pluck(data, "longitude"));

  _.each(pindata, function(num){ 

  map.objects.add(new nokia.maps.map.Circle(
  new nokia.maps.geo.Coordinate(num[0], num[1]), 40000,
  { pen: { strokeColor: "black", lineWidth: 0 }, brush: { color: "yellow" }}));
  });
  eof
end

#stylesheetsObject



13
14
15
# File 'lib/generators/ovimap/helpers.rb', line 13

def stylesheets
  "#{asset_path}/stylesheets"
end