Пример #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //MGLAccountManager.AccessToken = @"";

            var mapView = new MGLMapView(
                View.Bounds);

            this.View.AddSubview(mapView);
            mapView.WeakDelegate = this;

            mapView.SetCenterCoordinate(new CLLocationCoordinate2D(21.028511, 105.804817), 11, false);

            var temple = new MGLPointAnnotation
            {
                Title      = "Temple of literature",
                Subtitle   = "Van Mieu - Quoc Tu Giam",
                Coordinate = new CLLocationCoordinate2D(21.0276, 105.8355)
            };

            mapView.AddAnnotation(temple);

            var newLayer = new MGLSymbolStyleLayer(Guid.NewGuid().ToString(), new MGLSource("xxx"))
            {
                IconImageName = NSExpression.FromConstant(new NSString("temple")),
                IconOpacity   = NSExpression.FromConstant(NSNumber.FromDouble(0.7))
            };
        }
Пример #2
0
        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(40.7326808, -73.9843407), 12, false);

            // Set the delegate property of our map view to `self` after instantiating it.
            mapView.WeakDelegate = this;

            View.AddSubview(mapView);

            // Declare the marker `hello` and set its coordinates, title, and subtitle.
            var hello = new MGLPointAnnotation();

            hello.Coordinate = new CLLocationCoordinate2D(40.7326808, -73.9843407);
            hello.Title      = "Hello world!";
            hello.Subtitle   = "Welcome to my marker";

            // Add marker `hello` to the map.
            mapView.AddAnnotation(hello);
        }
Пример #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
            var mapView = new MGLMapView(
                View.Bounds,
                new NSUrl("mapbox://styles/naxamtest/cj5kin5x21li42soxdx3mb1yt")
                );

            this.View.AddSubview(mapView);
            mapView.WeakDelegate = this;

            mapView.SetCenterCoordinate(new CLLocationCoordinate2D(21.028511, 105.804817), 11, false);

            var temple = new MGLPointAnnotation()
            {
                Title      = "Temple of literature",
                Subtitle   = "Van Mieu - Quoc Tu Giam",
                Coordinate = new CLLocationCoordinate2D(21.0276, 105.8355)
            };

            mapView.AddAnnotation(temple);

            var newLayer = new MGLSymbolStyleLayer(Guid.NewGuid().ToString(), new MGLSource("xxx"))
            {
                IconImageName = NSExpression.FromConstant(new NSString("temple")),
                IconOpacity   = NSExpression.FromConstant(NSNumber.FromDouble(0.7))
            };

            Debug.WriteLine(newLayer.IconImageName.ToString());
        }
Пример #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            MGLAccountManager.AccessToken = "YOUR API KEY HERE";


            var mapView = new MGLMapView(
                View.Bounds,
                new NSUrl("mapbox://styles/mapbox/light-v9")
                )
            {
                WeakDelegate = this
            };

            var center = new CLLocationCoordinate2D(29.7604, -95.3698);

            // Starting point
            mapView.SetCenterCoordinate(center, zoomLevel: 8, direction: 0, animated: false);

            // Zoom levels
            mapView.MinimumZoomLevel = 8;
            mapView.MaximumZoomLevel = 15;

            View.AddSubview(mapView);
        }
Пример #5
0
        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.SetCenterCoordinate(new CLLocationCoordinate2D(45.520486, -122.673541), 11, false);
            mapView.WeakDelegate = this;

            View.AddSubview(mapView);

            DrawShape();
        }
Пример #6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            // Fill in the next line with your style URL from Mapbox Studio.
            var styleURL = new NSUrl("https://www.mapbox.com/ios-sdk/files/mapbox-raster-v8.json");

            mapView = new MGLMapView(View.Bounds, styleURL);

            // Set the map’s center coordinate and zoom level.
            mapView.SetCenterCoordinate(new CLLocationCoordinate2D(45.52954, -122.72317), 14, false);

            View.AddSubview(mapView);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            // Third party vector tile sources can be added.
            // In this case we're using custom style JSON (https://www.mapbox.com/mapbox-gl-style-spec/) to add a third party tile source: <https://vector.mapzen.com/osm/all/{z}/{x}/{y}.mvt>
            var customStyleURL = NSBundle.MainBundle.PathForResource("third_party_vector_style", "json");

            mapView           = new MGLMapView(View.Bounds, new NSUrl(customStyleURL));
            mapView.TintColor = UIColor.White;

            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.

            // 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);
        }
Пример #10
0
        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.

            // Create a MapView and set the coordinates/zoom
            mapView = new MGLMapView(View.Bounds);
            mapView.SetCenterCoordinate(new CLLocationCoordinate2D(37.745395, -119.594421), false);
            mapView.SetZoomLevel(11, false);

            View.AddSubview(mapView);

            mapView.WeakDelegate = this;

            button       = new UIButton(UIButtonType.RoundedRect);
            button.Frame = new CoreGraphics.CGRect(10, 10, 150, 40);
            button.SetTitle("Toggle Contours", UIControlState.Normal);
            button.Selected       = true;
            button.TouchUpInside += Button_TouchUpInside;
            mapView.Add(button);
        }
Пример #12
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
            var mapView = new MGLMapView(
                View.Bounds,
                new NSUrl("mapbox://styles/naxamtest/cj5kin5x21li42soxdx3mb1yt")
                );

            this.View.AddSubview(mapView);
            mapView.WeakDelegate = this;

            mapView.SetCenterCoordinate(new CLLocationCoordinate2D(21.028511, 105.804817), 11, false);

            var temple = new MGLPointAnnotation()
            {
                Title      = "Temple of literature",
                Subtitle   = "Van Mieu - Quoc Tu Giam",
                Coordinate = new CLLocationCoordinate2D(21.0276, 105.8355)
            };

            mapView.AddAnnotation(temple);
        }
        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());
        }
Пример #14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            /*Dictionary<string, CLLocationCoordinate2D> boundsDict = FindBounds(lat1, lng1, lat2, lng2);*/

            var lat1          = 21.353550;
            var lng1          = -157.842061;
            var lat2          = 35.832595;
            var lng2          = 139.535024;
            var pickupPoint   = new CLLocationCoordinate2D(lat1, lng1);
            var deliveryPoint = new CLLocationCoordinate2D(lat2, lng2);

            var initialBounds = new MGLCoordinateBounds()
            {
                sw = pickupPoint,
                ne = deliveryPoint
            };

            var mapView = new MGLMapView(frame: View.Bounds)
            {
                //This can be cleaned up at the end

/*                ZoomLevel = 6,
 *              CenterCoordinate = new CLLocationCoordinate2D(28.903782, -36.516551),
 *              VisibleCoordinateBounds = initialBounds,
 *              Direction = 0*/
            };

            bool crossesMeridianOrDateline;

            if ((lng1 > 0.0 && lng2 < 0.0) || (lng1 < 0.0 && lng2 > 0.0))
            {
                crossesMeridianOrDateline = true;
            }
            else
            {
                crossesMeridianOrDateline = false;
            }

            var xDiffPrimeMeridianZero = FindXDiffPrimeMeridianZero(lng1, lng2);
            var xDiffDatelineZero      = FindXDiffDatelineZero(lng1, lng2);

            List <double> xList;
            List <double> lngList;

            if ((Math.Abs(xDiffDatelineZero) > Math.Abs(xDiffPrimeMeridianZero)) && crossesMeridianOrDateline == true)
            {
                var latCenter = (lat1 + lat2) / 2.0;

                // Find center coordinate here
                var    x1      = FindXPrimeMeridianZero(lng1);
                var    xCenter = x1 + (xDiffPrimeMeridianZero / 2.0);
                double lngCenter;

                if (x1 > 180.0)
                {
                    lngCenter = xCenter - 360.0;
                }
                else
                {
                    lngCenter = xCenter;
                }

                mapView.SetCenterCoordinate(new CLLocationCoordinate2D(latCenter, lngCenter), false);
                mapView.SetZoomLevel(1.5, false);

                xList   = CreateXList(xDiffPrimeMeridianZero, x1);
                lngList = ConvertToLngsPrimeMeridianZero(xList);
            }
            else
            {
                // find max/min lat/lng here
                // use those to determine the initialBounds

                var latDict = FindLowHigh(lat1, lat2);
                var latHigh = latDict["high"];
                var latLow  = latDict["low"];
                var lngDict = FindLowHigh(lng1, lng2);
                var lngHigh = lngDict["high"];
                var lngLow  = lngDict["low"];

                var latBuffer = (latHigh - latLow) / 10.0;
                var lngBuffer = (lngHigh - lngLow) / 10.0;

                var swLat = latLow - latBuffer;
                var swLng = lngLow - lngBuffer;
                var neLat = latHigh + latBuffer;
                var neLng = lngHigh + lngBuffer;

                var bounds = new MGLCoordinateBounds()
                {
                    sw = new CLLocationCoordinate2D(swLat, swLng),
                    ne = new CLLocationCoordinate2D(neLat, neLng)
                };

                mapView.SetVisibleCoordinateBounds(bounds, new UIEdgeInsets(top: 0.0f, left: 0.0f, bottom: 0.0f, right: 0.0f), false);

                xList   = CreateXList(xDiffDatelineZero, FindXDatelineZero(lng1));
                lngList = ConvertToLngsDatelineZero(xList);
            }

            var yList = CreateYList(lat1, lat2);

            var latList = ConvertToLats(yList);
            var coords  = ConvertToCoords(latList, lngList);


            this.View.AddSubview(mapView);
            mapView.WeakDelegate = this;

/*            mapView.SetCenterCoordinate(new CLLocationCoordinate2D(50.392381, -98.94189), 6, false);*/

            var pickupPointAnnotation = new MGLPointAnnotation()
            {
                Title      = "Echo Chicago",
                Subtitle   = "#1 3PL",
                Coordinate = pickupPoint
            };

            var deliveryPointAnnotation = new MGLPointAnnotation()
            {
                Title      = "St. Louis",
                Subtitle   = "Delivery Spot",
                Coordinate = deliveryPoint
            };

            mapView.AddAnnotation(pickupPointAnnotation);
            mapView.AddAnnotation(deliveryPointAnnotation);

            CreateDashedLine(coords, mapView);

            /*			var newLayer = new MGLSymbolStyleLayer(Guid.NewGuid().ToString(), new MGLSource("xxx"))
             *          {
             *              IconImageName = NSExpression.FromConstant(new NSString("temple")),
             *              IconOpacity = NSExpression.FromConstant(NSNumber.FromDouble(0.7))
             *          };
             *          Debug.WriteLine(newLayer.IconImageName.ToString());*/
        }