Exemplo n.º 1
0
        /// <summary>
        /// Handle the event of the longpress on the MapView.
        /// MapView에서 longpress의 이벤트를 처리합니다.
        /// </summary>
        /// <param name="sender">Specifies the sender object</param>
        /// <param name="e">Specifies the occured event</param>
        private void MapViewLongPressed(object sender, MapGestureEventArgs e)
        {
            // Set the zoom level
            if (s_mapview.ZoomLevel < 13)
            {
                s_mapview.ZoomLevel = 13;
            }

            // Check the viewpage
            if (view == ViewPage.MAP)
            {
                // Remove the used data
                ClearData();
                // Move to the longpressed position
                // longpressed 지점을 이동합니다.
                s_mapview.Center = e.Geocoordinates;
                // Add the pin to the center positon of the map view
                // map view 중앙 지점에 핀을 추가합니다.
                s_mapview.Add(new Pin(s_mapview.Center));
                // Request the address by the center position of the map view and display the address to the label of the starting position
                // map view의 중앙의 주소를 요청하고 시작 위치의 label에 주소를 표시합니다.
                RequestAddress(s_mapview.Center.Latitude, s_mapview.Center.Longitude);
            }
            else if (view == ViewPage.ROUTE)
            {
                if (fromPosition != null && toPosition != null)
                {
                    // Remove the used data
                    ClearData();
                }

                // Move to the longpressed position
                s_mapview.Center = e.Geocoordinates;

                // Check the text of the from the label
                // label의 텍스트를 확인합니다.
                // null이면
                if (fromPosition == null)
                {
                    // Add a marker to the center position
                    // 중앙에 마커를 추가합니다.
                    s_mapview.Add(new Pin(s_mapview.Center));
                    // Create the Geocoordinates from the center position
                    // 중앙에서 Geocoordinates를 생성합니다.
                    fromPosition = new Geocoordinates(s_mapview.Center.Latitude, s_mapview.Center.Longitude);
                }
                // null이 아니면
                else
                {
                    // Add a marker to the center position
                    s_mapview.Add(new Sticker(s_mapview.Center));
                    // Create the Geocoordinates from the center position
                    toPosition = new Geocoordinates(s_mapview.Center.Latitude, s_mapview.Center.Longitude);
                    // Request a route with the fromPosition and the toPosition
                    // 출발지점과 도착지점의 route를 요청합니다.
                    RequestRoute(fromPosition, toPosition);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Views the did load.
        /// </summary>

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            unHideNavigationBar(this.NavigationController);
            setupNavigationBackground(this.NavigationController);
            this.NavigationController.NavigationBar.TintColor = UIColor.White;
            this.Title = "SOCIAL CIRCLE";
            GlobalLocation globalLocation = new GlobalLocation(this, true);

            GradientBackgroundForButton(msgButton);
            msgButton.Layer.CornerRadius = 4;
            msgButton.ClipsToBounds      = true;
            CornerRadius(35, addButton);
            NavigationController.NavigationBar.Translucent = false;
            if (!string.IsNullOrEmpty(Settings.UserLatSettings))
            {
                GlobalLocation globalLocation_Local = new GlobalLocation(this, true);
                camera = CameraPosition.FromCamera(latitude: Convert.ToDouble(Settings.UserLatSettings),
                                                   longitude: Convert.ToDouble(Settings.UserLongSettings), zoom: 12, bearing: 44, viewingAngle: 10);
                mapView = MapView.FromCamera(CGRect.Empty, camera);
                if (mapView != null)
                {
                    mapView.MyLocationEnabled = true;
                    mapView.Animate(camera);
                }
            }
            else
            {
                camera  = CameraPosition.FromCamera(latitude: 30.7108, longitude: 76.7094, zoom: 12, bearing: 44, viewingAngle: 10);
                mapView = MapView.FromCamera(CGRect.Empty, camera);
                mapView.MyLocationEnabled = true;
            }

            var fitBoundsButton = new UIBarButtonItem("", UIBarButtonItemStyle.Plain, DidTapFitBounds);

            fitBoundsButton.Image             = UIImage.FromBundle("Image-1");
            NavigationItem.RightBarButtonItem = fitBoundsButton;
            customButton1.Frame = new CGRect(8, 5, 45, 45);
            customButton2.Frame = new CGRect(View.Frame.X + View.Frame.Width - 53, 5, 45, 45);
            customButton3.Frame = new CGRect(View.Frame.X + View.Frame.Width - 53, customButton2.Frame.Y + customButton2.Frame.Height + 5, 45, 45);
            msgButton.Frame     = new CGRect(20, View.Frame.Height - 140, View.Frame.Width - 40, 45);
            addButton.Frame     = new CGRect(View.Frame.X + View.Frame.Width - 80, View.Frame.Height - 230, addButton.Frame.Width, addButton.Frame.Height);
            mapView.Add(msgButton);
            mapView.Add(addButton);
            mapView.Add(customButton1);
            mapView.Add(customButton2);
            mapView.Add(customButton3);
            View = mapView;

            mapView.Delegate = new CustomMapDelegate(mapView); //Call Delegate of MapView
            markers          = new List <Marker>();            // Initialize marker list
            HandleClicks();                                    //Button Clicks
            CreateCircle();                                    //Circle with static radius
        }
        /// <summary>
        /// Handle the event of the longpress on the MapView.
        /// </summary>
        /// <param name="sender">Specifies the sender object</param>
        /// <param name="e">Specifies the occured event</param>
        private void MapViewLongPressed(object sender, MapGestureEventArgs e)
        {
            // Check the viewpage
            if (view == ViewPage.MAP)
            {
                // Remove all the map object from the map view
                s_mapview.RemoveAll();
                // Set the zoom level
                s_mapview.ZoomLevel = 13;
                // Move to the longpressed position
                s_mapview.Center = e.Geocoordinates;
                // Add the pin to the center positon of the map view
                s_mapview.Add(new global::Tizen.Maps.Pin(s_mapview.Center));
                // Request the address by the center position of the map view and display the address to the label of the starting position
                RequestAddress(fromLabel, s_mapview.Center.Latitude, s_mapview.Center.Longitude);
            }
            else if (view == ViewPage.ROUTE)
            {
                // Set the zoom level
                s_mapview.ZoomLevel = 13;
                // Check the text of the fromLabel and the toLabel. The route is being displayed if the text of the labels is not empty.
                if ((fromLabel.Text != "" && toLabel.Text != "") || (fromLabel.Text == "" && toLabel.Text == ""))
                {
                    // Remove the used resource
                    ClearData();
                }

                // Move to the longpressed position
                s_mapview.Center = e.Geocoordinates;

                // Check the text of the from the label
                if (fromPosition == null)
                {
                    // Add a marker to the center position
                    s_mapview.Add(new global::Tizen.Maps.Pin(s_mapview.Center));
                    // Request an address with the center position
                    RequestAddress(fromLabel, s_mapview.Center.Latitude, s_mapview.Center.Longitude);
                    // Create the Geocoordinates from the center position
                    fromPosition = new Geocoordinates(s_mapview.Center.Latitude, s_mapview.Center.Longitude);
                }
                else if (fromLabel.Text != "" && toPosition == null)
                {
                    // Add a marker to the center position
                    s_mapview.Add(new global::Tizen.Maps.Sticker(s_mapview.Center));
                    // Request an address with the center position
                    RequestAddress(toLabel, s_mapview.Center.Latitude, s_mapview.Center.Longitude);
                    // Create the Geocoordinates from the center position
                    toPosition = new Geocoordinates(s_mapview.Center.Latitude, s_mapview.Center.Longitude);
                    // Request a route with the fromPosition and the toPosition
                    RequestRoute(fromPosition, toPosition);
                }
            }
        }
        /// <summary>
        /// Handle the event of the longpress on the MapView.
        /// </summary>
        /// <param name="sender">Specifies the sender object</param>
        /// <param name="e">Specifies the occured event</param>
        private void MapViewLongPressed(object sender, MapGestureEventArgs e)
        {
            // Set the zoom level
            if (s_mapview.ZoomLevel < 13)
            {
                s_mapview.ZoomLevel = 13;
            }

            // Check the viewpage
            if (view == ViewPage.MAP)
            {
                // Remove the used data
                ClearData();
                // Move to the longpressed position
                s_mapview.Center = e.Geocoordinates;
                // Add the pin to the center positon of the map view
                s_mapview.Add(new Pin(s_mapview.Center));
                // Request the address by the center position of the map view and display the address to the label of the starting position
                RequestAddress(s_mapview.Center.Latitude, s_mapview.Center.Longitude);
            }
            else if (view == ViewPage.ROUTE)
            {
                if (fromPosition != null && toPosition != null)
                {
                    // Remove the used data
                    ClearData();
                }

                // Move to the longpressed position
                s_mapview.Center = e.Geocoordinates;

                // Check the text of the from the label
                if (fromPosition == null)
                {
                    // Add a marker to the center position
                    s_mapview.Add(new Pin(s_mapview.Center));
                    // Create the Geocoordinates from the center position
                    fromPosition = new Geocoordinates(s_mapview.Center.Latitude, s_mapview.Center.Longitude);
                }
                else
                {
                    // Add a marker to the center position
                    s_mapview.Add(new Sticker(s_mapview.Center));
                    // Create the Geocoordinates from the center position
                    toPosition = new Geocoordinates(s_mapview.Center.Latitude, s_mapview.Center.Longitude);
                    // Request a route with the fromPosition and the toPosition
                    RequestRoute(fromPosition, toPosition);
                }
            }
        }
Exemplo n.º 5
0
        public override async Task OnInitializing()
        {
            Items = await RidesService.GetUserRides(refresher : Refresh);

            await base.OnInitializing();


            if (Items != null && Items.Length > 0)
            {
                var Item = Items[0];
                await MapView.Add(new Map.Annotation
                {
                    Title    = Item.From,
                    Location = new Zebble.Services.GeoLocation(Item.FromStation.Latitude, Item.FromStation.Longitude)
                });

                await MapView.Add(new Map.Annotation
                {
                    Title    = Item.To,
                    Location = new Zebble.Services.GeoLocation(Item.ToStation.Latitude, Item.ToStation.Longitude)
                });

                MapView.Center = new Zebble.Services.GeoLocation(((Item.ToStation.Latitude + Item.FromStation.Latitude) / 2), ((Item.ToStation.Longitude + Item.FromStation.Longitude) / 2));
            }
            else
            {
                await MapView.Add(new Map.Annotation
                {
                    Title    = GlobalSettings.City,
                    Location = new Zebble.Services.GeoLocation(GlobalSettings.EventLatitude, GlobalSettings.EventLongitude)
                });
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Request a route between two positions.
        /// </summary>
        /// <param name="from">Specifies the starting position</param>
        /// <param name="to">Specifies the end position</param>
        public async void RequestRoute(Geocoordinates from, Geocoordinates to)
        {
            try
            {
                // Request a route with between two positions
                var response = await s_maps.CreateRouteSearchRequest(from, to).GetResponseAsync();

                // Get the route
                IEnumerator <Route> route = response.GetEnumerator();
                while (route.MoveNext())
                {
                    // Display the polylines after making it from the path of the route
                    if (view == ViewPage.ROUTE)
                    {
                        s_mapview.Add(new Polyline((List <Geocoordinates>)route.Current.Path, Color.Red, 5));
                    }
                }
            }
            catch (Exception e)
            {
                // Display logs with the error message
                Log.Debug("Map", e.Message.ToString());
            }
        }
Exemplo n.º 7
0
        public override async Task OnInitializing()
        {
            await base.OnInitializing();

            MapView.ZoomLevel = 11;
            RouteSelector.Y.Set(10);
            RouteSelected.Y.Set(Root.ActualHeight - 230);
            FromItemPicker.SelectionChanged.Handle(FSelectionChanged);
            ToItemPicker.SelectionChanged.Handle(TSelectionChanged);
            var nearestStations = await RidesService.GetNearestStations();

            if (nearestStations != null)
            {
                await MapView.Add(new Map.Annotation
                {
                    Title    = nearestStations[0].Name,
                    Location = new Zebble.Services.GeoLocation(nearestStations[0].Latitude, nearestStations[0].Longitude)
                });

                InitializePinsFromStations(await RidesService.GetNearestStations());
                FromItemPicker.DataSource = CustomPins.ToList();
                ToItemPicker.DataSource   = CustomPins.ToList();
            }
        }
        public override async Task OnInitializing()
        {
            From = Nav.Param <CustomPin>("from");
            To   = Nav.Param <CustomPin>("to");

            await base.OnInitializing();

            MainStack.Y.Set((float)0);


            await MapView.Add(new Map.Annotation
            {
                Title    = From.Label,
                Location = new Zebble.Services.GeoLocation(From.Position.Latitude, From.Position.Longitude)
            });

            await MapView.Add(new Map.Annotation
            {
                Title    = To.Label,
                Location = new Zebble.Services.GeoLocation(To.Position.Latitude, To.Position.Longitude)
            });

            MapView.ZoomLevel = 14;
        }