Example #1
0
        public MapPageCS()
        {
            var customMap = new CustomMap {
                MapType = MapType.Street,
                WidthRequest = App.ScreenWidth,
                HeightRequest = App.ScreenHeight
            };

            customMap.RouteCoordinates.Add (new Position (37.797534, -122.401827));
            customMap.RouteCoordinates.Add (new Position (37.797510, -122.402060));
            customMap.RouteCoordinates.Add (new Position (37.790269, -122.400589));
            customMap.RouteCoordinates.Add (new Position (37.790265, -122.400474));
            customMap.RouteCoordinates.Add (new Position (37.790228, -122.400391));
            customMap.RouteCoordinates.Add (new Position (37.790126, -122.400360));
            customMap.RouteCoordinates.Add (new Position (37.789250, -122.401451));
            customMap.RouteCoordinates.Add (new Position (37.788440, -122.400396));
            customMap.RouteCoordinates.Add (new Position (37.787999, -122.399780));
            customMap.RouteCoordinates.Add (new Position (37.786736, -122.398202));
            customMap.RouteCoordinates.Add (new Position (37.786345, -122.397722));
            customMap.RouteCoordinates.Add (new Position (37.785983, -122.397295));
            customMap.RouteCoordinates.Add (new Position (37.785559, -122.396728));
            customMap.RouteCoordinates.Add (new Position (37.780624, -122.390541));
            customMap.RouteCoordinates.Add (new Position (37.777113, -122.394983));
            customMap.RouteCoordinates.Add (new Position (37.776831, -122.394627));

            customMap.MoveToRegion (MapSpan.FromCenterAndRadius (new Position (37.79752, -122.40183), Distance.FromMiles (1.0)));
            Content = customMap;
        }
Example #2
0
		public MapPageCS ()
		{
			var customMap = new CustomMap {
				MapType = MapType.Street,
				WidthRequest = App.ScreenWidth,
				HeightRequest = App.ScreenHeight
			};

			var pin = new Pin {
				Type = PinType.Place,
				Position = new Position (37.79752, -122.40183),
				Label = "Xamarin San Francisco Office",
				Address = "394 Pacific Ave, San Francisco CA"
			};

			var position = new Position (37.79752, -122.40183);
			customMap.Circle = new CustomCircle {
				Position = position,
				Radius = 1000
			};

			customMap.Pins.Add (pin);
			customMap.MoveToRegion (MapSpan.FromCenterAndRadius (position, Distance.FromMiles (1.0)));

			Content = customMap;
		}
Example #3
0
        public MapPageCS()
        {
            var customMap = new CustomMap {
                MapType = MapType.Street,
                WidthRequest = App.ScreenWidth,
                HeightRequest = App.ScreenHeight
            };

            customMap.ShapeCoordinates.Add (new Position (37.797513, -122.402058));
            customMap.ShapeCoordinates.Add (new Position (37.798433, -122.402256));
            customMap.ShapeCoordinates.Add (new Position (37.798582, -122.401071));
            customMap.ShapeCoordinates.Add (new Position (37.797658, -122.400888));

            customMap.MoveToRegion (MapSpan.FromCenterAndRadius (new Position (37.79752, -122.40183), Distance.FromMiles (0.1)));
            Content = customMap;
        }
Example #4
0
        public MapPageCS()
        {
            api = new AirQualityAPI();

            customMap = new CustomMap {
                MapType         = MapType.Street,
                WidthRequest    = App.ScreenWidth,
                HeightRequest   = 400,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            resultsLabel = new Label
            {
                Text            = "",
                VerticalOptions = LayoutOptions.FillAndExpand,
                FontSize        = 20
            };

            searchBar = new SearchBar
            {
                Placeholder       = "Search for location",
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                SearchCommand     = new Command(() => { resultsLabel.Text = "Result: " + searchBar.Text + " is what you asked for\n Here is a new piece of data!"; })
            };

            // Get user's current location.
            Task.Run(async() => { await GetUserPositionAsync(); });
            while (userLat == 0.0 || userLong == 0.0)
            {
            }

            // Gets the nearest air quality station.
            Console.WriteLine(string.Format("LAT:{0}, LONG: {1}", userLat, userLong));
            var      geoResult       = api.GeolocalisedFeed(userLat, userLong);
            Position stationPosition = new Position(geoResult.data.city.geo[0], geoResult.data.city.geo[1]);
            //Position position = new Position(50.3792423, -4.1401285);
            var closestStationPin = new Pin
            {
                Type     = PinType.Place,
                Position = stationPosition,
                Label    = geoResult.data.city.name,
                Address  = string.Format("Touch me to view Health Alert", geoResult.data.aqi)
            };

            closestStationPin.Clicked += (sender, e) =>
            {
                DisplayAlert(string.Format("{0} - Health Alert", geoResult.data.city.name), string.Format("Air Quality Index is {0}", geoResult.data.aqi), "OK");
            };

            // Create the heatmap for the station and give it the air quality index to
            // evaluate the colour to show.
            customMap.Circle = new CustomCircle(geoResult.data.aqi, stationPosition);

            //var position = new Position (37.79752, -122.40183);
            //customMap.Circle = new CustomCircle {
            //	Position = position,
            //	Radius = 1000
            //};

            customMap.Pins.Add(closestStationPin);

            customMap.MoveToRegion(MapSpan.FromCenterAndRadius(stationPosition, Distance.FromMiles(1.0)));

            //Content = customMap;
            Content = new StackLayout {
                Spacing  = 0,
                Children =
                {
                    searchBar,
                    new ScrollView
                    {
                        Content         = resultsLabel,
                        VerticalOptions = LayoutOptions.FillAndExpand
                    },
                    customMap
                }
            };
        }