Class: Osmaps::MainController

Inherits:
Volt::ModelController
  • Object
show all
Defined in:
app/osmaps/controllers/main_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



3
4
# File 'app/osmaps/controllers/main_controller.rb', line 3

def index
end

#map(latitude, longitude, opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'app/osmaps/controllers/main_controller.rb', line 6

def map(latitude, longitude, opts = {})
  `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});`
  zoom = opts[:zoom] || 15
  `var map = L.map('osmaps').setView([latitude, longitude], 15).addLayer(osm);`
  if opts[:title]
    title = opts[:title]
    `L.marker([ latitude, longitude]).addTo(map).bindPopup(title);`
  end
  return nil
end