Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
Images
Resources
AppDelegate.cs
Info.plist
Main.cs
MapView.csproj
MapView.sln
MapViewController.cs
README.md

README.md

id title brief article sdk
959DD891-9C05-6D5E-1AB5-DFDA09D9D845
Change Map Modes
This recipe shows how to change the type of map being displayed in an MKMapView to either Road, Satellite or Hybrid.

Recipe

To change the mode of a MKMapView:

  1. Start with an existing MKMapView or review the Displaying a Location recipe.
  2. Change the map type in code using one of these statements:
mapView.MapType = MKMapType.Standard; // the default, road map
mapView.MapType = MKMapType.Satellite;
mapView.MapType = MKMapType.Hybrid;

  1. To add a segment control to allow the user to switch between modes, add the following code:
int typesWidth=260, typesHeight=30, distanceFromBottom=60;
mapTypes = new UISegmentedControl(new CGRect((View.Bounds.Width-typesWidth)/2, View.Bounds.Height-distanceFromBottom, typesWidth, typesHeight));
mapTypes.BackgroundColor = UIColor.White;
mapTypes.Layer.CornerRadius = 5;
mapTypes.ClipsToBounds = true;
mapTypes.InsertSegment("Road", 0, false);
mapTypes.InsertSegment("Satellite", 1, false);
mapTypes.InsertSegment("Hybrid", 2, false);
mapTypes.SelectedSegment = 0; // Road is the default
mapTypes.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin;
mapTypes.ValueChanged += (s, e) => {
    switch(mapTypes.SelectedSegment) {
    case 0:
        mapView.MapType = MKMapType.Standard;
        break;
    case 1:
        mapView.MapType = MKMapType.Satellite;
        break;
    case 2:
        mapView.MapType = MKMapType.Hybrid;
        break;
    }
};