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



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

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

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



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

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

#map_providerObject



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

def map_provider
  Calagator.mapping_provider || "stamen"
end

#map_provider_dependenciesObject



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

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



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

def mapping_js_includes
  leaflet_js + map_provider_dependencies
end