Sha256: 9e56c0d055f4d369ea63aad3fc0b43de0e5aef0fd2173952deb1dee0bf9b960c

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

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.1 motion/map_view.rb