Skip to content

Commit 39394dc

Browse files
authored
Merge pull request #510 from codeforjapan/develop
Fix markers in dynamic_map #509
2 parents 9f603a2 + 11da9b3 commit 39394dc

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

config/initializers/decidim_override.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,29 @@
3535
end
3636
end
3737
end
38+
39+
module Decidim
40+
module Map
41+
class DynamicMap < Map::Frontend
42+
class Builder < Decidim::Map::Frontend::Builder
43+
# Overwrite
44+
def map_element(html_options = {})
45+
opts = view_options
46+
opts["markers"] = opts["markers"].reject { |item| item[:latitude].nil? || item[:latitude].nan? } if opts["markers"].present?
47+
map_html_options = {
48+
"data-decidim-map" => opts.to_json,
49+
# The data-markers-data is kept for backwards compatibility
50+
"data-markers-data" => opts.fetch(:markers, []).to_json
51+
}.merge(html_options)
52+
53+
content = template.capture { yield }.html_safe if block_given?
54+
55+
template.content_tag(:div, map_html_options) do
56+
(content || "")
57+
end
58+
end
59+
end
60+
end
61+
end
62+
end
3863
end

0 commit comments

Comments
 (0)