lib/ProMotion/map/map_screen_module.rb in ProMotion-mapbox-0.1.1 vs lib/ProMotion/map/map_screen_module.rb in ProMotion-mapbox-0.1.2
- old
+ new
@@ -10,11 +10,10 @@
def screen_setup
mapbox_setup
self.view = nil
self.view = RMMapView.alloc.initWithFrame(self.view.bounds, andTilesource:@tileSource)
self.view.delegate = self
-
check_annotation_data
@promotion_annotation_data = []
set_up_tap_to_add
end
@@ -29,15 +28,16 @@
end
def view_will_appear(animated)
super
update_annotation_data
+ set_up_start_center
end
def view_did_appear(animated)
super
- set_up_start_position
+ set_up_start_region
end
def check_annotation_data
PM.logger.error "Missing #annotation_data method in MapScreen #{self.class.to_s}." unless self.respond_to?(:annotation_data)
end
@@ -183,15 +183,27 @@
initialLocation = CLLocationCoordinate2D.new(params[:latitude], params[:longitude])
region = create_region(initialLocation,params[:radius])
set_region(region, animated:false)
end
- def set_up_start_position
+ def set_up_start_region
if self.class.respond_to?(:get_start_position) && self.class.get_start_position
- self.set_start_position self.class.get_start_position_params
+ start_params = self.class.get_start_position_params
+ self.set_start_position start_params unless start_params[:radius].nil?
end
end
+
+ def set_up_start_center
+ if self.class.respond_to?(:get_start_position) && self.class.get_start_position
+ start_params = self.class.get_start_position_params
+ start_params[:zoom] ||= 5
+ self.view.setZoom(start_params[:zoom], atCoordinate:
+ CLLocationCoordinate2D.new(start_params[:latitude], start_params[:longitude]),
+ animated: false
+ )
+ end
+ end
def set_tap_to_add(params={})
params = {
length: 2.0,
target: self,
@@ -335,12 +347,19 @@
PM.logger.info("You're trying to reverse geocode something that isn't a CLLocation")
callback.call nil, nil
end
end
+ def empty_cache
+ map.removeAllCachedImages
+ end
+
########## Mapbox methods #################
def mapView(map_view, layerForAnnotation: annotation)
+ if annotation.is_a?(RMAnnotation)
+ annotation = MapScreenAnnotation.new_with_rmannotation(annotation,self.view)
+ end
annotation_view(map_view, annotation)
end
########## Cocoa touch methods #################
def mapView(map_view, didUpdateUserLocation:userLocation)
@@ -365,9 +384,12 @@
elsif self.respond_to?(:on_change_region)
on_change_region
end
end
+ def tapOnCalloutAccessoryControl(control, forAnnotation: annotation, onMap: map)
+ control.sendActionsForControlEvents(UIControlEventTouchUpInside)
+ end
########## Cocoa touch Ruby counterparts #################
def deceleration_mode
map.decelerationMode
end