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



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

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

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



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

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

#map_providerObject



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

def map_provider
  Calagator.mapping_provider || 'stamen'
end

#map_provider_dependenciesObject



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

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' => ['https://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



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

def mapping_js_includes
  leaflet_js + map_provider_dependencies
end