Class: MapKit::DataTypes::CoordinateRegion

Inherits:
Object
  • Object
show all
Includes:
CoreLocation::DataTypes
Defined in:
lib/map-kit-wrapper/map_kit_data_types.rb

Overview

Wrapper for MKCoordinateRegion

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CoordinateRegion

CoordinateRegion.new(CoordinateRegion) CoordinateRegion.new(MKCoordinateRegion) CoordinateRegion.new([56, 10.6], [3.1, 3.1]) CoordinateRegion.new(=> {:latitude => 56, :longitude => 10.6, :span => => 3.1, :longitude_delta => 3.1} CoordinateRegion.new(LocationCoordinate, CoordinateSpan) CoordinateRegion.new(CLLocationCoordinate2D, MKCoordinateSpan)



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 73

def initialize(*args)
  self.center, self.span =
      case args.size
        when 1
          arg = args[0]
          case arg
            when Hash
              [arg[:center], arg[:span]]
            else
              [arg.center, arg.span]
          end
        when 2
          [args[0], args[1]]
      end
end

Instance Attribute Details

#centerObject

Returns the value of attribute center.



65
66
67
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 65

def center
  @center
end

#spanObject

Returns the value of attribute span.



65
66
67
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 65

def span
  @span
end

Instance Method Details

#sdkObject



89
90
91
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 89

def sdk
  MKCoordinateRegionMake(@center.sdk, @span.sdk)
end

#to_hObject



101
102
103
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 101

def to_h
  {:center => @center.to_h, :span => @span.to_h}
end

#to_sObject



105
106
107
# File 'lib/map-kit-wrapper/map_kit_data_types.rb', line 105

def to_s
  to_h.to_s
end