コード例 #1
0
        /// <summary>
        /// Remove the used resource.
        /// </summary>
        public void ClearData()
        {
            // Clear the marker list
            MarkerList.Clear();

            // Clear the place list
            if (PlaceList != null)
            {
                PlaceList.Clear();
            }
            // Remove all the map object from the map view
            if (s_mapview != null)
            {
                s_mapview.RemoveAll();
            }
            // Clear the fromLabel's text
            if (fromLabel != null)
            {
                fromLabel.Text = "";
            }
            // Clear the toLabel's text
            if (toLabel != null)
            {
                toLabel.Text = "";
            }

            PlaceList    = null;
            fromPosition = null;
            toPosition   = null;
        }
コード例 #2
0
        void UpdateVisibleRegion()
        {
            int width  = Control.Geometry.Width;
            int height = Control.Geometry.Height;
            int x      = Control.Geometry.X;
            int y      = Control.Geometry.Y;

            Geocoordinates ul = Control.ScreenToGeolocation(new ElmSharp.Point {
                X = x, Y = y
            });
            Geocoordinates ur = Control.ScreenToGeolocation(new ElmSharp.Point {
                X = x + width, Y = y
            });
            Geocoordinates ll = Control.ScreenToGeolocation(new ElmSharp.Point {
                X = x, Y = y + height
            });
            Geocoordinates lr = Control.ScreenToGeolocation(new ElmSharp.Point {
                X = x + width, Y = y + height
            });

            double dlat  = Math.Max(Math.Abs(ul.Latitude - lr.Latitude), Math.Abs(ur.Latitude - ll.Latitude));
            double dlong = Math.Max(Math.Abs(ul.Longitude - lr.Longitude), Math.Abs(ur.Longitude - ll.Longitude));

            Element.SetVisibleRegion(new MapSpan(new Position(Control.Center.Latitude, Control.Center.Longitude), dlat, dlong));
        }
コード例 #3
0
        public bool Start_Run()
        {
            if (_runStatus != Rstatus.Paused &&
                _runStatus != Rstatus.Stopped)
            {
                return(false);
            }

            // subscribe to gps updates
            Geocoordinates geolocator = Geocoordinates.GetGeolocator();

            if (_runStatus == Rstatus.Paused)
            {
                geolocator.ResumeRun();
            }
            else // _runStatus == Rstatus.Stopped
            {
                geolocator.StartNewRun();
            }
            geolocator.SubscribeToUpdates();

            _runStatus = Rstatus.Started;
            CollapseAll();
            ShowActive();

            return(true);
        }
コード例 #4
0
        /// <summary>
        /// Remove the used resource.
        /// </summary>
        public void ClearData()
        {
            // Remove the index of the current marker
            CurrentMarker = 0;
            // Clear the marker list
            MarkerList.Clear();

            if (PlaceList != null)
            {
                // Clear the place list
                PlaceList.Clear();
            }
            // Remove all the map object from the map view
            if (s_mapview != null)
            {
                s_mapview.RemoveAll();
            }
            // Clear the fromBtn's text
            if (fromBtn != null)
            {
                fromBtn.Text = "";
            }
            // Clear the toBtn's text
            if (toBtn != null)
            {
                toBtn.Text = "";
            }

            PlaceList    = null;
            fromPosition = null;
            toPosition   = null;
        }
コード例 #5
0
        private static Stream PozicijaPrekrsaja(decimal latitude, decimal longitude, out string koordinate)
        {
            try
            {
                koordinate = Geocoordinates.DDtoDMS((double)latitude, Geocoordinates.CoordinateType.latitude) + ", " + Geocoordinates.DDtoDMS((double)longitude, Geocoordinates.CoordinateType.longitude);

                try
                {
                    WebRequest req = WebRequest.Create(Geocoordinates.PozicijaPrekrsajaGM(latitude.ToString().Replace(",", "."), longitude.ToString().Replace(",", ".")));
                    req.Timeout = 5000; //10sec
                    WebResponse response = req.GetResponse();
                    Stream      stream   = response.GetResponseStream();
                    return(stream);
                }
                catch (Exception)
                {
                    WebRequest  req      = WebRequest.Create(Geocoordinates.PozicijaPrekrsajaOS(latitude.ToString().Replace(",", "."), longitude.ToString().Replace(",", ".")));
                    WebResponse response = req.GetResponse();
                    Stream      stream   = response.GetResponseStream();
                    return(stream);
                }
            }
            catch (Exception ex)
            {
                koordinate = "";
                return(null);
            }
        }
コード例 #6
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);
                }
            }
        }
コード例 #7
0
 /// <summary>
 /// Initializes Area class.
 /// </summary>
 /// <param name="topLeftPoint">Top left point of the area.</param>
 /// <param name="bottomRightPoint">Bottom right of the area.</param>
 public Area(Geocoordinates topLeftPoint, Geocoordinates bottomRightPoint)
 {
     TopLeftPoint     = topLeftPoint;
     BottomRightPoint = bottomRightPoint;
     CenterPoint      = new Geocoordinates(
         (topLeftPoint.Latitude + bottomRightPoint.Latitude) / 2,
         (topLeftPoint.Longitude + bottomRightPoint.Longitude) / 2);
 }
コード例 #8
0
        /// <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);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Request pois with the position and the category.
        /// </summary>
        /// <param name="coordinate">Specifies the starting position</param>
        /// <param name="Category">Specifies the end position</param>
        public async void RequestPOI(Geocoordinates coordinate, string Category)
        {
            try
            {
                // Set the category
                s_maps.PlaceSearchFilter.Category.Id = Category;
                /// Request pois with the position and the category.
                var response = await s_maps.CreatePlaceSearchRequest(coordinate, 500).GetResponseAsync();

                // Get the places
                IEnumerator <Place> place = response.GetEnumerator();
                // Create the list for places
                PlaceList = new List <Place>();
                while (place.MoveNext())
                {
                    // Add the place to the list
                    PlaceList.Add(place.Current);
                }

                // Sort by distance
                PlaceList = PlaceList.OrderBy(x => x.Distance).ToList();
                for (int i = 0; i < PlaceList.Count; i++)
                {
                    // Create pins with the places and add it to marker list
                    MarkerList.Add(new global::Tizen.Maps.Pin(PlaceList[i].Coordinates));
                    // Show the markers
                    if (view == ViewPage.POI)
                    {
                        s_mapview.Add(MarkerList[i]);
                    }
                    // Add a handler to click the marker
                    MarkerList[i].Clicked += (sender, e) => { SetCurrentMarker((Marker)sender); };
                }

                // Set the current marker
                if (view == ViewPage.POI)
                {
                    SetCurrentMarker(MarkerList[0]);
                }
            }
            catch (Exception e)
            {
                // Display logs with the error message
                Log.Debug("Map", e.Message.ToString());
            }
            // Set the viewpage
            if (view == ViewPage.POI)
            {
                view = ViewPage.POISELECTED;
            }
        }
コード例 #10
0
        /// <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);
                }
            }
        }
コード例 #11
0
 void AddPins(IEnumerable pins)
 {
     foreach (Pin pin in pins)
     {
         var coordinates = new Geocoordinates(pin.Position.Latitude, pin.Position.Longitude);
         var nativePin   = new TPin(coordinates);
         nativePin.Clicked += (s, e) =>
         {
             pin.SendTap();
         };
         Control.Add(nativePin);
         _pins.Add(pin, nativePin);
     }
 }
コード例 #12
0
        public bool Stop_Run()
        {
            if (_runStatus != Rstatus.Paused)
            {
                return(false);
            }

            Geocoordinates.GetGeolocator().StopRun();

            _runStatus = Rstatus.Stopped;
            CollapseAll();
            ShowActive();

            return(true);
        }
コード例 #13
0
 void AddPins(IEnumerable pins)
 {
     foreach (Pin pin in pins)
     {
         pin.PropertyChanged += PinOnPropertyChanged;
         var coordinates = new Geocoordinates(pin.Position.Latitude, pin.Position.Longitude);
         var nativePin   = new TPin(coordinates);
         pin.MarkerId       = nativePin;
         nativePin.Clicked += (s, e) =>
         {
             pin.SendMarkerClick();
         };
         Control.Add(nativePin);
         _pins.Add(pin);
     }
 }
コード例 #14
0
        void ApplyIsShowingUser(Geocoordinates coordinates)
        {
            if (_marker == null)
            {
                _marker           = new Sticker(coordinates);
                _marker.IsVisible = false;
                Control.Add(_marker);
            }
            _marker.Coordinates = coordinates;

            if (!_marker.IsVisible)
            {
                _marker.IsVisible = true;
                Control.Center    = coordinates;
                Control.ZoomLevel = 13;
            }
        }
コード例 #15
0
        void AddPins(IEnumerable pins)
        {
            foreach (Pin pin in pins)
            {
                pin.PropertyChanged += PinOnPropertyChanged;
                var coordinates = new Geocoordinates(pin.Position.Latitude, pin.Position.Longitude);
                var nativePin   = new TPin(coordinates);
                pin.MarkerId       = nativePin;
                nativePin.Clicked += (s, e) =>
                {
#pragma warning disable CS0618
                    pin.SendTap();
#pragma warning restore CS0618
                };
                Control.Add(nativePin);
                _pins.Add(pin);
            }
        }
コード例 #16
0
        /// <summary>
        /// Request a route between two positions.
        /// 두 지점 사이의 route 요청
        /// </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
            {
                view = ViewPage.ROUTE_IN_PROGRESS;
                // Request a route with between two positions
                // 두 지점 사이의 route를 요청합니다.
                var response = await s_maps.CreateRouteSearchRequest(from, to).GetResponseAsync();

                // Get the route
                // route 가져오기
                IEnumerator <Route> route = response.GetEnumerator();

                route.MoveNext();

                if (view == ViewPage.ROUTE_IN_PROGRESS)
                {
                    // Display the polylines after making it from the path of the route
                    // route의 경로에서 polylines를 만든 후 표시합니다.
                    s_mapview.Add(new Polyline((List <Geocoordinates>)route.Current.Path, ElmSharp.Color.Red, 5));

                    string distance;
                    if (route.Current.Unit == DistanceUnit.Kilometer)
                    {
                        distance = string.Format("{0,10:N2}", route.Current.Distance);
                    }
                    else
                    {
                        distance = string.Format("{0,10:N2}", route.Current.Distance / 1000);
                    }

                    string duration = string.Format("{0,10:N2}", route.Current.Duration / 60);

                    CreatePopup(distance + " km / " + duration + " min by car");

                    view = ViewPage.ROUTE;
                }
            }
            catch (Exception e)
            {
                // Display logs with the error message
                Log.Debug("Map", e.Message.ToString());
            }
        }
コード例 #17
0
        /// <summary>
        /// Remove the used resource.
        /// </summary>
        public void ClearData()
        {
            // Clear the marker list
            MarkerList.Clear();

            if (PlaceList != null)
            {
                // Clear the place list
                PlaceList.Clear();
            }

            PlaceList = null;

            // Remove all the map object from the map view
            if (s_mapview != null)
            {
                s_mapview.RemoveAll();
            }

            fromPosition = null;
            toPosition   = null;
        }
コード例 #18
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());
            }
        }
コード例 #19
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals("VisibleRegion") && viewReady && !isDrawn)
            {
                Control.RemoveAll();

                var scale        = ElmSharp.Elementary.GetScale();
                int windowWidth  = (int)Math.Round(OverlayWidth * scale);
                int windowHeight = (int)Math.Round(OverlayHeight * scale);

                foreach (var pin in customPins)
                {
                    var coordinates = new Geocoordinates(pin.Position.Latitude, pin.Position.Longitude);

                    Control.Add(new TPin(coordinates, PinPath));

                    int width  = windowWidth;
                    int height = windowHeight;

                    var window = new ElmSharp.Box(Control);
                    window.Show();

                    {
                        var overlay = new ElmSharp.Box(window)
                        {
                            BackgroundColor = XamarinLogoColor,
                        };
                        overlay.SetAlignment(-1.0, -1.0);                     // fill
                        overlay.SetWeight(1.0, 0.0);                          // expand on X axis
                        overlay.Show();
                        window.PackEnd(overlay);

                        if (pin.Id == XamarinId)
                        {
                            var xamarin = new ElmSharp.Image(overlay);
                            xamarin.Load(XamarinPath);
                            xamarin.SetAlignment(-1.0, -1.0);                              // fill
                            var size = xamarin.ObjectSize;
                            xamarin.MinimumWidth  = size.Width;
                            xamarin.MinimumHeight = size.Height;
                            xamarin.Show();
                            overlay.PackEnd(xamarin);

                            height += size.Height;
                        }

                        {
                            var infoBox = new ElmSharp.Box(overlay)
                            {
                                IsHorizontal = true,
                            };
                            infoBox.SetAlignment(-1.0, -1.0);                         // fill
                            infoBox.SetWeight(1.0, 0.0);                              // expand on X axis
                            infoBox.Show();
                            overlay.PackEnd(infoBox);

                            {
                                var monkey = new ElmSharp.Image(infoBox);
                                monkey.Load(MonkeyPath);
                                monkey.SetAlignment(-1.0, -1.0);                             // fill
                                monkey.SetWeight(1.0, 0.0);                                  // expand on X axis
                                monkey.Show();
                                infoBox.PackEnd(monkey);
                            }

                            {
                                var textBox = new ElmSharp.Box(infoBox);
                                textBox.SetAlignment(-1.0, -1.0);                             // fill
                                textBox.SetWeight(1.0, 0.0);                                  // expand on X axis
                                textBox.Show();
                                infoBox.PackEnd(textBox);

                                {
                                    var title = new NLabel(textBox)
                                    {
                                        Text           = pin.Label,
                                        FontAttributes = FontAttributes.Bold,
                                        TextColor      = ElmSharp.Color.White,
                                    };
                                    title.SetAlignment(-1.0, -1.0);                                 // fill
                                    title.SetWeight(1.0, 0.0);                                      // expand on X axis
                                    title.Show();
                                    textBox.PackEnd(title);
                                }

                                {
                                    var subtitle = new NLabel(textBox)
                                    {
                                        Text      = pin.Address,
                                        TextColor = ElmSharp.Color.White,
                                    };
                                    subtitle.SetAlignment(-1.0, -1.0);                                 // fill
                                    subtitle.SetWeight(1.0, 0.0);                                      // expand on X axis
                                    subtitle.Show();
                                    textBox.PackEnd(subtitle);
                                }
                            }

                            {
                                var info = new ElmSharp.Image(infoBox);
                                info.Load(InfoPath);
                                info.SetAlignment(-1.0, -1.0);                             // fill
                                info.SetWeight(1.0, 0.0);                                  // expand on X axis
                                info.Show();
                                infoBox.PackEnd(info);
                            }
                        }
                    }

                    {
                        var expander = new ElmSharp.Box(window);
                        expander.SetAlignment(-1.0, -1.0);                     // fill
                        expander.SetWeight(1.0, 1.0);                          // expand
                        expander.Show();
                        window.PackEnd(expander);
                    }

                    window.Resize(width, height);

                    Control.Add(new Overlay(coordinates, window));
                }

                isDrawn = true;
            }
        }
コード例 #20
0
        /// <summary>
        /// Display the buttons.
        /// </summary>
        public void CreateButton()
        {
            // Create the button for the starting position
            fromBtn = new Button(win)
            {
                // Set the default text
                Text = "",
                // Set the default color
                Color = Color.Red,
                // Set the default background color
                BackgroundColor = Color.Gray
            };
            // Move the button
            fromBtn.Move(580, 45);
            // Resize the button
            fromBtn.Resize(1300, 80);
            // Show the button
            fromBtn.Show();
            // Set the handler for the button. Remove the focus from the button when it is clocked
            fromBtn.Clicked += (sender, e) => { ((Button)sender).SetFocus(false); };

            // Create the button for the end position
            toBtn = new Button(win)
            {
                // Set the default text
                Text = "",
                // Set the default color
                Color = Color.Red,
                // Set the default background color
                BackgroundColor = Color.Gray
            };
            // Move the button
            toBtn.Move(580, 130);
            // Resize the button
            toBtn.Resize(1300, 80);
            // Add the handler for this button. The focus of the button will be removed if it is clicked
            toBtn.Clicked += (sender, e) => { ((Button)sender).SetFocus(false); };

            // Create the button for the map viewpage
            MapBtn = new Button(win)
            {
                // Set the default text
                Text = "Map",
                // Set the default color
                Color = Color.White,
                // Set the default background color
                BackgroundColor = Color.Gray
            };
            // Move the button
            MapBtn.Move(50, 100);
            // Resize the button
            MapBtn.Resize(250, 100);
            // Show the button
            MapBtn.Show();
            // Focus on this button
            MapBtn.SetFocus(true);

            // Create the button for the route viewpage
            RouteBtn = new Button(win)
            {
                // Set the default text
                Text = "Route",
                // Set the default color
                Color = Color.White,
                // Set the default background color
                BackgroundColor = Color.Gray
            };
            // Move the button
            RouteBtn.Move(50, 200);
            // Resize the button
            RouteBtn.Resize(250, 100);
            // Show the button
            RouteBtn.Show();

            // Create the button for the poi viewpage
            PoiBtn = new Button(win)
            {
                // Set the default text
                Text = "POI",
                // Set the default color
                Color = Color.White,
                // Set the default background color
                BackgroundColor = Color.Gray
            };
            // Move the button
            PoiBtn.Move(50, 300);
            // Resize the button
            PoiBtn.Resize(250, 100);
            // Show the button
            PoiBtn.Show();

            // Create a list for the the button of the poi's category
            POIBtnList = new List <Button>();
            // Get the categories of the here provider
            foreach (string category in HereCategory)
            {
                // Add the category's button to the list
                POIBtnList.Add(new Button(win)
                {
                    Text = category
                });
            }

            for (int i = 0; i < POIBtnList.Count; i++)
            {
                // Set the default color for the category buttons
                POIBtnList[i].Color = Color.White;
                // Move the category buttons
                POIBtnList[i].Move(50, 400 + (i * 80));
                // Resize the category buttons
                POIBtnList[i].Resize(250, 80);
                // Add the handler for the category buttons
                POIBtnList[i].Clicked += (sender, e) =>
                {
                    // Set the viewpage
                    view = ViewPage.POI;
                    // Remove the used data
                    ClearData();
                    // Hide the button for the end position
                    toBtn.Hide();
                    // Request the pois with the center position
                    RequestPOI(new Geocoordinates(s_mapview.Center.Latitude, s_mapview.Center.Longitude), ((Button)sender).Text);
                };
            }

            // Add the handler for the map button
            MapBtn.Clicked += (sender, e) =>
            {
                // Remove the used data
                ClearData();
                // Hide the button for the end position
                toBtn.Hide();
                for (int i = 0; i < POIBtnList.Count; i++)
                {
                    // Hide the category buttons
                    POIBtnList[i].Hide();
                }
                // Set the viewpage
                view = ViewPage.MAP;
            };

            // Add the handler for the route button
            RouteBtn.Clicked += (sender, e) =>
            {
                // Remove the used data
                ClearData();
                // Show the button for the end position
                toBtn.Show();
                for (int i = 0; i < POIBtnList.Count; i++)
                {
                    // Hide the category buttons
                    POIBtnList[i].Hide();
                }
                // Set the viewpage
                view = ViewPage.ROUTE;
            };

            // Add the handler for the poi button
            PoiBtn.Clicked += (sender, e) =>
            {
                // Remove the used data
                ClearData();
                // Hide the button for the end position
                toBtn.Hide();
                for (int i = 0; i < POIBtnList.Count; i++)
                {
                    // Show the category buttons
                    POIBtnList[i].Show();
                }
                // Set the viewpage
                view = ViewPage.POI;
            };

            // Create the list for the direction buttons
            DirectionBtnList = new List <Button>();
            foreach (string direction in DirectionText)
            {
                // Create buttons and add it to the list
                DirectionBtnList.Add(new Button(win)
                {
                    // Set the default text
                    Text = direction,
                    // Set the default color
                    Color = Color.White,
                    // Set the default background color
                    BackgroundColor = Color.Gray
                });
            }

            for (int i = 0; i < DirectionBtnList.Count; i++)
            {
                if (i % 2 == 0)
                {
                    // Move the direction buttons
                    DirectionBtnList[i].Move(380, 100 + 100 * (i / 2));
                }
                else
                {
                    // Move the direction buttons
                    DirectionBtnList[i].Move(470, 100 + 100 * (i / 2));
                }

                // Resize the direction buttons
                DirectionBtnList[i].Resize(80, 80);
                // Show the direction buttons
                DirectionBtnList[i].Show();
                // Add the handler for the direction buttons
                DirectionBtnList[i].Clicked += (sender, e) =>
                {
                    Button selectedBtn = ((Button)sender);
                    // Check the clicked button
                    if (selectedBtn == DirectionBtnList[0])
                    {
                        // Zoom in
                        s_mapview.ZoomLevel = s_mapview.ZoomLevel + 1;
                    }
                    else if (selectedBtn == DirectionBtnList[1])
                    {
                        // Zoom out
                        s_mapview.ZoomLevel = s_mapview.ZoomLevel - 1;
                    }
                    else if (selectedBtn == DirectionBtnList[6])
                    {
                        // Check the viewpage
                        if (view == ViewPage.MAP)
                        {
                            // Remove all the map object from the map view
                            s_mapview.RemoveAll();
                            // Add the pin to the center position 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 button of the starting position
                            RequestAddress(fromBtn, s_mapview.Center.Latitude, s_mapview.Center.Longitude);
                        }
                        else if (view == ViewPage.ROUTE)
                        {
                            // Check the text of the from button and the to button. The route is being displayed if the text of the buttons is not empty.
                            if ((fromBtn.Text == "" && toBtn.Text == "") || (fromBtn.Text != "" && toBtn.Text != ""))
                            {
                                ClearData();
                            }

                            // Check the text of the from button
                            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(fromBtn, 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 (fromBtn.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(toBtn, 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);
                            }
                        }
                        else if (view == ViewPage.POISELECTED)
                        {
                            // Increase the index of the current marker
                            CurrentMarker = CurrentMarker + 1;
                            // Check the index of the current marker
                            if (CurrentMarker >= PlaceList.Count)
                            {
                                // Set 0 to the index if the index of the current marker is greater than the maximum value
                                CurrentMarker = 0;
                            }

                            // Display the current marker
                            SetCurrentMarker(CurrentMarker);
                        }
                    }
                    else
                    {
                        double variable = 0.0;
                        // Check the current zoom level
                        if (s_mapview.ZoomLevel >= 15)
                        {
                            // Set the value to move as the current zoom level
                            variable = 0.01;
                        }
                        else if (s_mapview.ZoomLevel >= 10)
                        {
                            // Set the value to move as the current zoom level
                            variable = 0.1;
                        }
                        else
                        {
                            // Set the value to move as the current zoom level
                            variable = 1.0;
                        }

                        // Check the selected button to determine the direction to move
                        if (selectedBtn == DirectionBtnList[3] || selectedBtn == DirectionBtnList[4])
                        {
                            // Set the value for the reverse direction
                            variable = -variable;
                        }

                        // Check the selected button to determine the direction to move
                        if (selectedBtn == DirectionBtnList[2] || selectedBtn == DirectionBtnList[3])
                        {
                            // Set the center position after creating the Geocoordinates with the calculated value
                            s_mapview.Center = new Geocoordinates(s_mapview.Center.Latitude + variable, s_mapview.Center.Longitude);
                        }
                        else
                        {
                            // Set the center position after creating the Geocoordinates with the calculated value
                            s_mapview.Center = new Geocoordinates(s_mapview.Center.Latitude, s_mapview.Center.Longitude + variable);
                        }
                    }
                };
            }
        }
コード例 #21
0
 /// <summary>
 /// Initializes class.
 /// </summary>
 /// <param name="permissionGranted">Defines if the permission was granted.</param>
 /// <param name="success">Value indicating if the request was successful.</param>
 /// <param name="result">Response result object.</param>
 public LocationServiceResponse(bool permissionGranted, bool success = false, Geocoordinates result = null)
 {
     PermissionGranted = permissionGranted;
     Success           = success;
     Result            = result;
 }
コード例 #22
0
        /*:: LOKACIJA ::*/

        public List <_DetaljiLokacije> DohvatiAdresu(double lat, double lng)
        {
            return(Geocoordinates.DohvatiAdresu(lat, lng));
        }