Module: Calagator::MappingHelper

Defined in:
app/helpers/calagator/mapping_helper.rb

Defined Under Namespace

Classes: Map

Instance Method Summary collapse

Instance Method Details

#leaflet_jsObject



8
9
10
# File 'app/helpers/calagator/mapping_helper.rb', line 8

def leaflet_js
  Rails.env.production? ? ["http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"] : ["leaflet"]
end

#map(items, options = {}) ⇒ Object



28
29
30
31
# File 'app/helpers/calagator/mapping_helper.rb', line 28

def map(items, options = {})
  options.symbolize_keys!
  Map.new(items, self, options).render
end

#map_providerObject



4
5
6
# File 'app/helpers/calagator/mapping_helper.rb', line 4

def map_provider
  Calagator.mapping_provider || 'stamen'
end

#map_provider_dependenciesObject



12
13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/calagator/mapping_helper.rb', line 12

def map_provider_dependencies
  {
    "stamen" => ["http://maps.stamen.com/js/tile.stamen.js?v1.2.3"],
    "mapbox" => ["https://api.tiles.mapbox.com/mapbox.js/v1.3.1/mapbox.standalone.js"],
    "esri"   => ["http://cdn-geoweb.s3.amazonaws.com/esri-leaflet/0.0.1-beta.5/esri-leaflet.js"],
    "google" => [
      "https://maps.googleapis.com/maps/api/js?key=#{Calagator.mapping_google_maps_api_key}&sensor=false",
      "leaflet_google_layer"
    ]
  }[map_provider] || []
end

#mapping_js_includesObject



24
25
26
# File 'app/helpers/calagator/mapping_helper.rb', line 24

def mapping_js_includes
  leaflet_js + map_provider_dependencies
end