Skip to content

Commit

Permalink
Added zoom to location fields (#1835)
Browse files Browse the repository at this point in the history
  • Loading branch information
iainbeeston committed Jul 7, 2023
1 parent c44faf4 commit 35597f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= field_wrapper **field_wrapper_args do %>
<% if field.value_present? %>
<%= js_map [{latitude: field.value[0], longitude: field.value[1]}], id: "location-map" %>
<%= js_map [{latitude: field.value[0], longitude: field.value[1]}], id: "location-map", zoom: field.zoom, controls: true %>
<% else %>
<% end %>
Expand Down
3 changes: 2 additions & 1 deletion lib/avo/fields/location_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
module Avo
module Fields
class LocationField < BaseField
attr_reader :stored_as
attr_reader :stored_as, :zoom

def initialize(id, **args, &block)
hide_on :index
super(id, **args, &block)

@stored_as = args[:stored_as].present? ? args[:stored_as] : nil # You can pass it an array of db columns [:latitude, :longitude]
@zoom = args[:zoom].present? ? args[:zoom].to_i : 15
end

def value_as_array?
Expand Down

0 comments on commit 35597f5

Please sign in to comment.