lib/ProMotion/map/map_screen_module.rb in ProMotion-map-0.6.0 vs lib/ProMotion/map/map_screen_module.rb in ProMotion-map-0.7.0

- old
+ new

@@ -1,8 +1,14 @@ module ProMotion module MapScreenModule + PIN_COLORS = { + red: MKPinAnnotationColorRed, + green: MKPinAnnotationColorGreen, + purple: MKPinAnnotationColorPurple + } + def screen_setup self.view = nil self.view = MKMapView.alloc.initWithFrame(self.view.bounds) self.view.delegate = self @@ -137,11 +143,11 @@ view = MKPinAnnotationView.alloc.initWithAnnotation(annotation, reuseIdentifier:identifier) end end view.image = params[:image] if view.respond_to?("image=") && params[:image] view.animatesDrop = params[:animates_drop] if view.respond_to?("animatesDrop=") - view.pinColor = params[:pin_color] if view.respond_to?("pinColor=") + view.pinColor = (PIN_COLORS[params[:pin_color]] || params[:pin_color]) if view.respond_to?("pinColor=") view.canShowCallout = params[:show_callout] if view.respond_to?("canShowCallout=") if params[:left_accessory] view.leftCalloutAccessoryView = params[:left_accessory] end @@ -301,9 +307,25 @@ def mapView(map_view, didUpdateUserLocation:userLocation) if self.respond_to?(:on_user_location) on_user_location(userLocation) else PM.logger.info "You're tracking the user's location but have not implemented the #on_user_location(location) method in MapScreen #{self.class.to_s}." + end + end + + def mapView(map_view, regionWillChangeAnimated:animated) + if self.respond_to?("will_change_region:") + will_change_region(animated) + elsif self.respond_to?(:will_change_region) + will_change_region + end + end + + def mapView(map_view, regionDidChangeAnimated:animated) + if self.respond_to?("on_change_region:") + on_change_region(animated) + elsif self.respond_to?(:on_change_region) + on_change_region end end ########## Cocoa touch Ruby counterparts #################