I am trying a quick prototype project to see if what I want to do with Mapbox iOS SDK (route-me) and iOS MapKit is possible.
I would like to see if I can have the best of both worlds with MapBox's offline capability (and extras like clustering) but also still use the iOS map types. After some research (and help on SO) I found that Mapbox and iOS maps do not work together, you get to pick one or the other. I started to wonder what would happen if I lay a RMMapView (mapbox map) directory on top of the iOS map. Then in instances when I want to see the iOS map I could just set the RMMapViews basemap to transparent such that the iOS map directly beneath it would show through. Again two fold, you could use iOS maps if you wanted but I could also keep the mapbox markers drawn such that when you switch to the iOS map you do not need to re-draw markers.
Basically I have created a main view (Super View) and added two subviews (MKMapView and RMMapView), with RMMapView on top. I have already figured out how to make the base layer on the RMMapView transparent, and I can even add RMMarkers and they show nicely laid on top of the MKMapView.
My problem is with touch events and gestures. If I do this I need all touches and gestures that happen on the RMMapView, to still happen on the RMMapView but also happen on the MKMapView. I.E. if the base map on RMMapView is transparent but there is a marker in that view, when I scroll the map I need the RMMapView to move (such that the marker moves) along with the MKMapView.
What I have tried:
- Override hitTest. Problem with this approach is that once you do this the touch will only operate on the view you return. I need the touch to happen on both the RMMapView and the MKMapView.
- Created a gesture recognizer in my Super View. I then try to pass the touches on to both of my sub views. Really, really though this might work. But there are a couple problems from what I can tell. First I know both map views have scroll views on top of them so forwarding the touch to the MKMapView and RMMapView does not work. I think I would have to forward the touch to each maps scroll view.
So I don't think 1 would ever work, and I cannot get 2 to work. Anyone ever tried to do anything like this. Can 2 different view act on the same touch events or does the first view that gets the event win?
My design may be wrong too so if anyone has another suggestion please throw it out. Do realize though that I would like to stay away from modifying RMMapView, and cannot really mod MKMapView.
Most relevant post I could find was this: How to intercept touches events on a MKMapView or UIWebView objects?. But I don't want to intercept events on the MKMapView, I want to intercept them on the SuperView such that I can pass to both its sup views.
Thanks