I have a PageRenderer in xamarin iOS app which does display a label when navigated but as i add a map it does not get displayed.
Infact, it seems to get stuck at line 54:
iOSMap.Refresh();
Can anybody tell me what could be the problem?
01.
using
System;
02.
using
System.Drawing;
03.
using
Xamarin.Forms.Platform.iOS;
04.
using
MonoTouch.UIKit;
05.
using
Xamarin.Forms;
06.
using
Agtrix.Portable.Forms;
07.
using
ThinkGeo.MapSuite.Core;
08.
using
ThinkGeo.MapSuite.iOSEdition;
09.
using
Agtrix.iOS.Views;
10.
// This ExportRenderer command tells Xamarin.Forms to use this renderer
11.
// instead of the built-in one for this page
12.
[assembly:ExportRenderer(
typeof
(ThinkGeoPage),
typeof
(Agtrix.iOS.Renderers.ThinkGeoPageRenderer))]
13.
14.
namespace
Agtrix.iOS.Renderers
15.
{
16.
/// <summary>
17.
/// Render this page using platform-specific UIKit controls
18.
/// </summary>
19.
public
class
ThinkGeoPageRenderer : PageRenderer
20.
{
21.
//private MapView iOSMap;
22.
protected
override
void
OnElementChanged (VisualElementChangedEventArgs e)
23.
{
24.
base
.OnElementChanged (e);
25.
var page = e.NewElement
as
ThinkGeoPage;
26.
var view = NativeView;
27.
28.
29.
var hostViewController = ViewController;
30.
31.
var viewController =
new
UIViewController();
32.
33.
// var label = new UILabel (new RectangleF(0, 40, 320, 40));
34.
// label.Text = "3 " + page.Heading;
35.
//viewController.View.Add(label);
36.
MapView iOSMap =
new
MapView (
new
RectangleF(0, 40, 320, 40));
37.
// Set the main view frame
38.
viewController.View.Frame = UIScreen.MainScreen.Bounds;
39.
viewController.View.BackgroundColor = UIColor.White;
40.
viewController.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
41.
42.
43.
// Add ThinkGeo Location Marker.
44.
Marker thinkGeoLocation =
new
Marker();
45.
thinkGeoLocation.Position =
new
PointShape(-96.809523, 33.128675);
46.
thinkGeoLocation.Image = UIImage.FromBundle(
"Pin"
);
47.
MarkerOverlay markerOverlay =
new
MarkerOverlay();
48.
markerOverlay.Markers.Add(thinkGeoLocation);
49.
iOSMap.Overlays.Add(
"markerOverlay"
, markerOverlay);
50.
51.
// Add MapView to MainView
52.
//viewController.View.AddSubview(iOSMap);
53.
viewController.View.Add(iOSMap);
54.
iOSMap.Refresh();
55.
56.
57.
hostViewController.AddChildViewController (viewController);
58.
hostViewController.View.Add(viewController.View);
59.
60.
viewController.DidMoveToParentViewController (hostViewController);
61.
}
62.
}
63.
}