Basic map with TGMapView

Display a map using TallyGo's tiles. (If you want more features such as searching and starting navigation, consider using the map view controller .)

Note that TGMapView is a subclass of MGLMapView , so you can use any functionality provided by either class.

// Part 1: Initialize the view
let mapView = TGMapView(frame: view.bounds)
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
mapView.translatesAutoresizingMaskIntoConstraints = true

// Part 2: Customize it to your liking
mapView.tintColor = UIColor.green
mapView.zoomLevel = 12
mapView.showsUserLocation = true
mapView.setUserTrackingMode(.follow, animated: false)

// Part 3: Add it to your existing view
view.addSubview(mapView)
// Part 1: Initialize the view
TGMapView *mapView = [TGMapView.alloc initWithFrame:self.view.bounds];
mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
mapView.translatesAutoresizingMaskIntoConstraints = YES;

// Part 2: Customize it to your liking
mapView.tintColor = UIColor.greenColor;
mapView.zoomLevel = 12;
mapView.showsUserLocation = YES;
[mapView setUserTrackingMode:MGLUserTrackingModeFollow animated:NO];

// Part 3: Add it to your existing view
[self.view addSubview:mapView];

TGMapView also works great inside a Storyboard, as follows:

  1. Drag a UIView into your Storyboard
  2. Change its class to TGMapView
  3. Create an outlet for the view in your view controller
  4. Customize it to your liking as shown in part 2 (skip parts 1 and 3)
Expected Output
TallyGo
Check out the iOS Reference App to see this example in action.

Look for examples 202 and 203 in the app.