7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/helpers/gmaps/gmaps_helper.rb', line 7
def show_map_helper(model, opts={})
object = model
model_name = model.class.to_s.downcase
@address = object.location_address
@latitude = object.location_latitude
@longitude = object.location_longitude
opts = {allow: 'show', searchbox: 'show', width: '800px', height: '400px', latitude: "#{@latitude}", longitude: "#{@longitude}", address: "#{@address}", zoom: 13, style: "border: 1px solid #green;", searchbox_width: '400px'}.merge(opts)
[
content_tag(:div, :id => "geopoint_search_box_container", style: " display: #{opts[:searchbox]}") do
tag(:input, type: :text, placeholder: 'Search', id: "gmaps_#{model_name}_search_box", style: "width: #{option[:searchbox_width]};")
end,
content_tag(:div, '', id: "map_canvas", style: "width: #{opts[:width]}; height: #{opts[:height]}; #{opts[:style]}"),
content_tag(:div, '', class: "data-location", data: {model: model_name, address:opts[:address], latitude: opts[:latitude] , longitude: opts[:longitude], zoom: opts[:zoom]}),
tag(:input, type: :hidden, value: "#{opts[:allow]}", name: "allow", id: "gmaps_map_allow"),
tag(:input, type: :hidden, value: "#{@latitude}", name: "#{model_name}[location_latitude]", id: "gmaps_location_latitude"),
tag(:input, type: :hidden, value: "#{@longitude}", name: "#{model_name}[location_longitude]", id: "gmaps_location_longitude"),
tag(:input, type: :hidden, value: "#{@address}", name: "#{model_name}[location_address]", id: "gmaps_location_address"),
javascript_tag("window.initJsMap();")
].join.html_safe
end
|