public void didFinishLoadingStyle(MGLMapView mGLMapView, MGLStyle mGLStyle) { nMap = mGLMapView; nStyle = mGLStyle; nMap.CompassView.Hidden = true; setupGestureRecognizer(); if (xMap?.initialCameraUpdate != null) updateMapPerspective(xMap.initialCameraUpdate); // Initialize route first so that it will be the first in the layer list z-index = 0 initializeRoutesLayer(); addAllRoutes(); // Add all pin first initializePinsLayer(); addAllReusablePinImages(); addAllPins(); // Then subscribe to pins added if (xMap.pins != null) xMap.pins.CollectionChanged += Pins_CollectionChanged; if (xMap.DefaultPins != null) xMap.DefaultPins.CollectionChanged += DefaultPins_CollectionChanged; if (xMap.routes != null) xMap.routes.CollectionChanged += Routes_CollectionChanged; // Subscribe to changes in map bindable properties after all pins are loaded xMap.PropertyChanged += Map_PropertyChanged; }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. mapView = new MGLMapView(View.Bounds, MGLStyle.LightStyleURLWithVersion(9)); mapView.TintColor = UIColor.DarkGray; // Set the map's bounds to Pisa, Italy. var bounds = new MGLCoordinateBounds() { sw = new CLLocationCoordinate2D(latitude: 43.7115, longitude: 10.3725), ne = new CLLocationCoordinate2D(latitude: 43.7318, longitude: 10.4222) }; mapView.SetVisibleCoordinateBounds(bounds, animated: false); // Set the map view‘s delegate property. mapView.WeakDelegate = this; View.AddSubview(mapView); // Initialize and add the point annotation. var pisa = new MGLPointAnnotation(); pisa.Coordinate = new CLLocationCoordinate2D(latitude: 43.72305, longitude: 10.396633); pisa.Title = "Leaning Tower of Pisa"; mapView.AddAnnotation(pisa); }
/** * Create a traffic plugin. * * @param mapView the MapView to apply the traffic plugin to * @param mapboxMap the MapboxMap to apply traffic plugin with * @param belowLayer the layer id where you'd like the traffic to display below */ public TrafficPlugin(MGLMapView mapboxMap, MGLStyle style, string belowLayer) { this.mapboxMap = mapboxMap; this.style = style; this.belowLayer = belowLayer; }
public void DidFinishLoadingStyle(MGLMapView mapView, MGLStyle style) { var emapStyle = Element.MapStyle ?? new MapStyle(); emapStyle.UrlString = mapView.StyleURL.AbsoluteString; emapStyle.Name = style.Name; Element.MapStyle = emapStyle; mapStyle = style; Element.Functions = this; Element.DidFinishLoadingStyleCommand?.Execute(emapStyle); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. // Create a MapView mapView = new MGLMapView(View.Bounds); mapView.StyleURL = MGLStyle.LightStyleURLWithVersion(9); mapView.TintColor = UIColor.DarkGray; mapView.SetZoomLevel(1, false); mapView.WeakDelegate = this; View.AddSubview(mapView); // Polyline // Create a coordinates array with all of the coordinates for our polyline. List <CLLocationCoordinate2D> coordinates = new List <CLLocationCoordinate2D>() { new CLLocationCoordinate2D(35, -25), new CLLocationCoordinate2D(20, -30), new CLLocationCoordinate2D(0, -25), new CLLocationCoordinate2D(-15, 0), new CLLocationCoordinate2D(-45, 10), new CLLocationCoordinate2D(-45, 40) }; var coords = coordinates.ToArray(); //TODO Use CustomPolyline MGLPolyline polyline = CustomPolyline.PolylineWithCoordinates(ref coords[0], (uint)coords.Count()); // Set the custom `color` property, later used in the `mapView:strokeColorForShapeAnnotation:` delegate method. //((CustomPolyline)polyline).Color = UIColor.DarkGray; // Add the polyline to the map. Note that this method name is singular. mapView.AddAnnotation(polyline); // Point Annotations // Add a custom point annotation for every coordinate (vertex) in the polyline. List <CustomPointAnnotation> pointAnnotations = new List <CustomPointAnnotation>(); foreach (var coordinate in coordinates) { CustomPointAnnotation point = new CustomPointAnnotation(coordinate, "Custom Point Annotation " + pointAnnotations.Count + 1, ""); pointAnnotations.Add(point); } mapView.AddAnnotations(pointAnnotations.ToArray()); }
void DidFinishLoadingStyle(MGLMapView mapView, MGLStyle style) { MapStyle newStyle; if (Element.MapStyle == null) { newStyle = new MapStyle(mapView.StyleURL.AbsoluteString); newStyle.Name = style.Name; Element.MapStyle = newStyle; } else { if (Element.MapStyle.UrlString == null || Element.MapStyle.UrlString != mapView.StyleURL.AbsoluteString) { Element.MapStyle.SetUrl(mapView.StyleURL.AbsoluteString); Element.MapStyle.Name = style.Name; } newStyle = Element.MapStyle; } if (Element.MapStyle.CustomSources != null) { var notifiyCollection = Element.MapStyle.CustomSources as INotifyCollectionChanged; if (notifiyCollection != null) { notifiyCollection.CollectionChanged += OnShapeSourcesCollectionChanged; } AddSources(Element.MapStyle.CustomSources.ToList()); } if (Element.MapStyle.CustomLayers != null) { if (Element.MapStyle.CustomLayers is INotifyCollectionChanged notifiyCollection) { notifiyCollection.CollectionChanged += OnLayersCollectionChanged; } AddLayers(Element.MapStyle.CustomLayers.ToList()); } newStyle.OriginalLayers = style.Layers.Select((MGLStyleLayer arg) => new Layer(arg.Identifier) { IsVisible = arg.Visible } ).ToArray(); newStyle.Name = style.Name; Element.DidFinishLoadingStyleCommand?.Execute(newStyle); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. // Create a MapView mapView = new MGLMapView(View.Bounds, MGLStyle.OutdoorsStyleURLWithVersion(9)); // Tint the i button and the user location annotation. mapView.TintColor = UIColor.DarkGray; // Set the map’s center coordinate and zoom level. mapView.SetCenterCoordinate(new CLLocationCoordinate2D(51.50713, -0.10957), 13, false); View.AddSubview(mapView); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. // A hybrid style with unobtrusive labels is also available via satelliteStreetsStyleURL(withVersion:). mapView = new MGLMapView(View.Bounds, MGLStyle.SatelliteStyleURLWithVersion(9)); // Tint the i button. mapView.AttributionButton.TintColor = UIColor.White; // Set the map’s center coordinate and zoom level. mapView.SetCenterCoordinate(new CLLocationCoordinate2D(45.5188, -122.6748), 13, false); View.AddSubview(mapView); }
void AddLayer(MGLStyle style) { var source = new MGLVectorSource(identifier: "contours", configurationURL: new NSUrl("mapbox://mapbox.mapbox-terrain-v2")); var layer = new MGLLineStyleLayer(identifier: "contours", source: source); layer.SourceLayerIdentifier = "contour"; layer.LineJoin = MGLStyleValue.ValueWithRawValue(NSValue.FromObject(MGLLineJoin.Round)); layer.LineCap = MGLStyleValue.ValueWithRawValue(NSValue.FromObject(MGLLineCap.Round)); layer.LineColor = MGLStyleValue.ValueWithRawValue(UIColor.Brown); layer.LineWidth = MGLStyleValue.ValueWithRawValue(NSValue.FromObject(1.0)); style.AddSource(source); style.AddLayer(layer); contoursLayer = layer; }
public LayersListViewController(MGLStyle style, string styleOwner, string styleId) : base(null, null) { tableView = new UITableView() { DataSource = this, Delegate = this, TranslatesAutoresizingMaskIntoConstraints = false }; tableView.RegisterClassForCellReuse(typeof(UITableViewCell), "ImageCell"); tableView.RegisterClassForCellReuse(typeof(UITableViewCell), "FillCell"); tableView.RegisterClassForCellReuse(typeof(UITableViewCell), "CircleCell"); tableView.RegisterClassForCellReuse(typeof(UITableViewCell), "LineCell"); Style = style; mbService = new MapboxService(); this.styleOwner = styleOwner; this.styleId = styleId; }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. mapView = new MGLMapView(View.Bounds, MGLStyle.LightStyleURLWithVersion(9)); // Set the map’s center coordinate and zoom level. mapView.SetCenterCoordinate(new CLLocationCoordinate2D(36.54, -116.97), 9, false); // Set the delegate property of our map view to `self` after instantiating it. mapView.WeakDelegate = this; View.AddSubview(mapView); MyCustomPointAnnotation pointA = new MyCustomPointAnnotation(); pointA.Coordinate = new CLLocationCoordinate2D(36.4623, -116.8656); pointA.Title = "Stovepipe Wells"; pointA.WillUseImage = true; MyCustomPointAnnotation pointB = new MyCustomPointAnnotation(); pointB.Coordinate = new CLLocationCoordinate2D(36.6071, -117.1458); pointB.Title = "Furnace Creek"; pointB.WillUseImage = true; MyCustomPointAnnotation pointC = new MyCustomPointAnnotation(); pointC.Coordinate = new CLLocationCoordinate2D(36.4208, -116.8101); pointC.Title = "Zabriskie Point"; MyCustomPointAnnotation pointD = new MyCustomPointAnnotation(); pointD.Coordinate = new CLLocationCoordinate2D(36.6836, longitude: -117.1005); pointD.Title = "Mesquite Flat Sand Dunes"; MyCustomPointAnnotation[] myPlaces = new MyCustomPointAnnotation[4] { pointA, pointB, pointC, pointD }; mapView.AddAnnotations(myPlaces);; }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. mapView = new MGLMapView(View.Bounds); // Set the map’s center coordinate and zoom level mapView.SetCenterCoordinate(new CLLocationCoordinate2D(0, 66), false); mapView.SetZoomLevel(2, false); mapView.StyleURL = MGLStyle.DarkStyleURLWithVersion(9); // Set the delegate property of our map view to `self` after instantiating it mapView.WeakDelegate = this; View.AddSubview(mapView); // Specify coordinates for our annotations. List <CLLocationCoordinate2D> coordinates = new List <CLLocationCoordinate2D>(); coordinates.Add(new CLLocationCoordinate2D(0, 33)); coordinates.Add(new CLLocationCoordinate2D(0, 66)); coordinates.Add(new CLLocationCoordinate2D(0, 99)); List <MGLPointAnnotation> pointAnnotations = new List <MGLPointAnnotation>(); // Fill an array with point annotations and add it to the map. foreach (var coord in coordinates) { MGLPointAnnotation point = new MGLPointAnnotation(); point.Coordinate = coord; point.Title = $"Lat: {coord.Latitude}, Long: {coord.Longitude}"; pointAnnotations.Add(point); } mapView.AddAnnotations(pointAnnotations.ToArray()); }
public void MapView(MGLMapView mapView, MGLStyle style) { AddLayer(style); }
/** * Create a traffic plugin. * * @param mapView the MapView to apply the traffic plugin to * @param mapboxMap the MapboxMap to apply traffic plugin with */ public TrafficPlugin(MGLMapView mapboxMap, MGLStyle style) : this(mapboxMap, style, null) { }