From 35597f509f2e3c0e2f985369c532da32359ad0e5 Mon Sep 17 00:00:00 2001 From: Iain Beeston Date: Fri, 7 Jul 2023 13:57:56 +0100 Subject: [PATCH] Added zoom to location fields (#1835) --- .../avo/fields/location_field/show_component.html.erb | 2 +- lib/avo/fields/location_field.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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?