Sha256: 0e9eb52c029968e118fc445b56ea17d018fcb3d5deda070f032a1c497429c9f0
Contents?: true
Size: 887 Bytes
Versions: 169
Compression:
Stored size: 887 Bytes
Contents
# frozen_string_literal: true module Avo module Fields class AreaField < BaseField attr_reader :mapkick_options attr_reader :datapoint_options def initialize(id, **args, &block) hide_on :index super(id, **args, &block) @geometry = args[:geometry].presence || :polygon # Accepts: `:polygon` or `:multi_polygon` @mapkick_options = args[:mapkick_options].presence || {} @datapoint_options = args[:datapoint_options].presence || {} end def map_data data_source = { geometry: { type: @geometry.to_s.classify, coordinates: value } } [data_source.merge(datapoint_options)] end def coordinates value.present? ? JSON.parse(value) : [] end def geometry @geometry.to_s.classify end end end end
Version data entries
169 entries across 169 versions & 1 rubygems