Class: MapKit::MapView

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

Overview

Wrapper for MKMapView

Constant Summary

Constants included from ZoomLevel

ZoomLevel::MERCATOR_OFFSET, ZoomLevel::MERCATOR_RADIUS

Instance Method Summary collapse

Methods included from ZoomLevel

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

Constructor Details

#initializeMapView

Returns a new instance of MapView.



16
17
18
# File 'lib/map-kit-wrapper/map_view.rb', line 16

def initialize
  self.alloc.init
end

Instance Method Details

#get_regionObject

Get the maps region



72
73
74
# File 'lib/map-kit-wrapper/map_view.rb', line 72

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

#region=(*args) ⇒ Object

Set the maps region



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

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

#scroll_enabled=(enabled) ⇒ Object

Set scroll on/off



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

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

#scroll_enabled?Boolean

Show if scroll is enbaled

Returns:

  • (Boolean)


34
35
36
# File 'lib/map-kit-wrapper/map_view.rb', line 34

def scroll_enabled?
  self.isScrollEnabled
end

#set_region(coordinate_region, *args) ⇒ Object

Set the maps region including animation



84
85
86
87
88
# File 'lib/map-kit-wrapper/map_view.rb', line 84

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

#shows_user_location=(enabled) ⇒ Object

Set visible user location on/off



52
53
54
# File 'lib/map-kit-wrapper/map_view.rb', line 52

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

#shows_user_location?Boolean

Show if the users location is on the map

Returns:

  • (Boolean)


46
47
48
# File 'lib/map-kit-wrapper/map_view.rb', line 46

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



66
67
68
# File 'lib/map-kit-wrapper/map_view.rb', line 66

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

#user_located?Boolean

Show if the users has been located yet

Returns:

  • (Boolean)


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

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

#zoom_enabled=(enabled) ⇒ Object

Set zoom on/off



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

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

#zoom_enabled?Boolean

Show if zoom is enabled

Returns:

  • (Boolean)


22
23
24
# File 'lib/map-kit-wrapper/map_view.rb', line 22

def zoom_enabled?
  self.isZoomEnabled
end