Class: MapKit::MapView

Inherits:
MKMapView
  • Object
show all
Includes:
CoreLocation::DataTypes, DataTypes, OverriddenMethods, ZoomLevel
Defined in:
lib/map-kit-wrapper/map_view.rb

Overview

Wrapper for MKMapView

Defined Under Namespace

Modules: OverriddenMethods

Constant Summary

Constants included from ZoomLevel

ZoomLevel::MERCATOR_OFFSET, ZoomLevel::MERCATOR_RADIUS

Instance Method Summary collapse

Methods included from OverriddenMethods

#region

Methods included from ZoomLevel

included, #set_center_coordinates, #set_map_lat_lon, #set_zoom_level, #zoom_level

Constructor Details

#initializeMapView

Initializer for MapView



19
20
21
# File 'lib/map-kit-wrapper/map_view.rb', line 19

def initialize
  self.alloc.init
end

Instance Method Details

#region=(args) ⇒ Object

Set the maps region



110
111
112
113
114
115
116
117
# File 'lib/map-kit-wrapper/map_view.rb', line 110

def region=(args)
  case args
    when Hash
      self.setRegion(CoordinateRegion.new(args[:region]).api, animated: args[:animated])
    else
      self.setRegion(CoordinateRegion.new(args).api, animated: false)
  end
end

#scroll_enabled=(enabled) ⇒ Object

Set scroll on/off

  • Args :

    • enabled -> Bool



59
60
61
# File 'lib/map-kit-wrapper/map_view.rb', line 59

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

#scroll_enabled?Boolean

Is scroll enbabled?

  • Returns :

    • Bool

Returns:

  • (Boolean)


49
50
51
# File 'lib/map-kit-wrapper/map_view.rb', line 49

def scroll_enabled?
  self.isScrollEnabled
end

#set_regionObject

Deprecated



122
123
124
# File 'lib/map-kit-wrapper/map_view.rb', line 122

def set_region
  raise 'set_region has been deprecated. Please review the docs on region=()'
end

#shows_user_location=(enabled) ⇒ Object

Set visible user location on/off

  • Args :

    • enabled -> Bool



79
80
81
# File 'lib/map-kit-wrapper/map_view.rb', line 79

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

#shows_user_location?Boolean

Is the users location shown on the map

  • Returns :

    • Bool

Returns:

  • (Boolean)


69
70
71
# File 'lib/map-kit-wrapper/map_view.rb', line 69

def shows_user_location?
  self.showsUserLocation
end

#user_coordinatesObject

Show the users coordinates. Defaults to nil if the functionality is turned off or the location has not yet been found

  • Returns :

    • LocationCoordinate



99
100
101
# File 'lib/map-kit-wrapper/map_view.rb', line 99

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

#user_located?Boolean

Has the user been located yet?

  • Returns :

    • Bool

Returns:

  • (Boolean)


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

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

#zoom_enabled=(enabled) ⇒ Object

Set zoom on/off

  • Args :

    • enabled -> Bool



39
40
41
# File 'lib/map-kit-wrapper/map_view.rb', line 39

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

#zoom_enabled?Boolean

Is zoom enabled

  • Returns :

    • Bool

Returns:

  • (Boolean)


29
30
31
# File 'lib/map-kit-wrapper/map_view.rb', line 29

def zoom_enabled?
  self.isZoomEnabled
end