Sha256: 8bfe13aef50dec21f7de2ee9b7ff265b24b7ccf888b9233c9b1f190ae03e8164

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

# require core_location_data_types
# require map_kit_data_types
# require zoom_level

module MapKit
  include CoreLocation::DataTypes
  include MapKit::DataTypes

  # Wrapper for MKMapView
  class MapView < MKMapView
    include CoreLocation::DataTypes
    include MapKit::DataTypes
    include MapKit::ZoomLevel

    def initialize
      self.alloc.init
    end

    # zoom methods

    def zoom_enabled?
      self.isZoomEnabled
    end

    def zoom_enabled=(enabled)
      self.setZoomEnabled(enabled)
    end

    # scroll methods

    def scroll_enabled?
      self.isScrollEnabled
    end

    def scroll_enabled=(enabled)
      self.setScrollEnabled(enabled)
    end

    # user location methods

    def shows_user_location?
      self.showsUserLocation
    end

    def shows_user_location=(enabled)
      self.showsUserLocation = enabled
    end

    def user_located?
      self.shows_user_location? && self.userLocation.location ? true : false
    end

    def user_coordinates
      self.user_located? ? LocationCoordinate.new(self.userLocation.location.coordinate) : nil
    end

    # region methods

    def get_region
      CoordinateRegion.new(self.region.center, self.region.span)
    end

    def region=(*args)
      self.set_region(CoordinateRegion.new(args.first), false)
    end

    def set_region(coordinate_region, *args)
      opts = {:animated => false}
      opts.merge!(args.first) if args.first
      self.setRegion(coordinate_region.sdk, animated:opts[:animated])
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
map-kit-wrapper-0.0.2 lib/map-kit-wrapper/map_view.rb