Ok I know, disclaimer, swizzling is risky and so on and so forth, but...here
goes.

I'm trying to follow the swizzle approach to disabling the drawing of the
google/apple basemap in MapKit, as described  here
<http://blog.sumbera.com/2011/09/18/how-to-disable-base-google-maps-in-mapkit/> 
 
in #3. Based on the pseudo code described in  this discussion
<http://lists.ximian.com/pipermail/monotouch/2012-April/009253.html>   for
doing it in MT, I've come up with this:

                [DllImport 
("/System/Library/Frameworks/Foundation.framework/Foundation")]
                static extern IntPtr class_getInstanceMethod (IntPtr a, IntPtr 
b);

                [DllImport 
("/System/Library/Frameworks/Foundation.framework/Foundation")]
                static extern IntPtr method_setImplementation (IntPtr a, IntPtr 
b);

                delegate void DrawLayerDelegate (IntPtr @this, IntPtr selector, 
CALayer
layer, CGContext context);

                [MonoPInvokeCallback (typeof (DrawLayerDelegate))]
                static void DrawLayer (IntPtr @this, IntPtr selector, CALayer 
layer,
CGContext context)
                {
                        // do nothing
                }
                static DrawLayerDelegate DrawLayerImplementation = DrawLayer;
        
                private void DisableBaseMap (UIView mapView)
                {
                        // -- get rendering layer
                        UIView rootView = mapView.Subviews[0];
                        UIView vkmapView = rootView.Subviews[0];
                        UIView vkmapCanvas = vkmapView.Subviews[0];
                        
                        IntPtr canvas_class = new Class (vkmapCanvas.GetType 
()).Handle;
                        IntPtr method = class_getInstanceMethod (canvas_class, 
new Selector
("drawLayer:inContext:").Handle);
                        IntPtr new_impl =
Marshal.GetFunctionPointerForDelegate(DrawLayerImplementation);
                        
                        method_setImplementation (method, new_impl);
                }



It builds, runs, but then get this:

    *System.Runtime.InteropServices.MarshalDirectiveException* has been
thrown
The type `MonoTouch.CoreAnimation.CALayer' layout needs to be Sequential or
Explicit

and at the top of the stack trace:

    System.Runtime.InteropServices.MarshalDirectiveException: The type
`MonoTouch.CoreAnimation.CALayer' layout needs to be Sequential or Explicit
  at (wrapper native-to-managed)
CgMobilePOC3.UI.Touch.Views.MainMapView:DrawLayer
(intptr,intptr,MonoTouch.CoreAnimation.CALayer,MonoTouch.CoreGraphics.CGContext)

Any ideas what might be missing/wrong?

Thanks!

Dennis



--
View this message in context: 
http://monotouch.2284126.n4.nabble.com/Disable-mapkit-basemap-tp4657590.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to