diff --git a/app/components/avo/fields/location_field/show_component.html.erb b/app/components/avo/fields/location_field/show_component.html.erb index a58fcb3913..acd773d788 100644 --- a/app/components/avo/fields/location_field/show_component.html.erb +++ b/app/components/avo/fields/location_field/show_component.html.erb @@ -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 %> diff --git a/lib/avo/fields/location_field.rb b/lib/avo/fields/location_field.rb index 8f39f32160..9d22f56864 100644 --- a/lib/avo/fields/location_field.rb +++ b/lib/avo/fields/location_field.rb @@ -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?