Example #1
0
        private async void map_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            if (useflag == true)
            {
                goalpoint = args.Location;
                using (SQLiteConnection conn = BicycleDatabase.GetDbConnection())
                {
                    TableQuery <Bicycle> t = conn.Table <Bicycle>();
                    var q = (from s in t
                             where s.bicycle_id == str
                             select s).SingleOrDefault();

                    (double x, double y) current_location_parse(string current_location)
                    {
                        var str = current_location.Split(',');

                        double.TryParse(str[0], out var x);
                        double.TryParse(str[1], out var y);
                        return(x, y);
                    }

                    Geopoint startpoint =
                        new Geopoint(new BasicGeoposition()
                    {
                        Latitude  = current_location_parse(q.current_location).x,
                        Longitude = current_location_parse(q.current_location).y
                    });
                    await routeCreateAsync(startpoint, goalpoint); //g1应为当前选择车辆的坐标

                    useflag = false;
                }
            }
        }
Example #2
0
        /// <summary>
        /// 鼠标点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">地图输入事件参数</param>
        private void OnClick(object sender, MapInputEventArgs e)
        {
            if (e.ClickPosition.x == -1 || e.ClickPosition.y == -1)
            {
                return;
            }
            //Debug.Log($"ClickButtomCoed:{e.ClickButtomCoed} ClickPosition:{e.ClickPosition}");

            if (this.SelectRoleEntity != null)
            {
                if (e.ClickButtomCoed == MouseButton.LeftMouse &&
                    this.SelectRoleEntity.RoleStatus.Status != RoleSkillStatus.Unselected)
                {
                    switch (this.SelectRoleEntity.RoleStatus.Status)
                    {
                    case RoleSkillStatus.Move:
                        this.MoveRole(e);
                        break;

                    case RoleSkillStatus.Skill:
                        this.ExecutionSkill(e);
                        break;

                    default:
                        throw new ArgumentException($"出现未处理的枚举:{this.SelectRoleEntity.RoleStatus.Status}");
                    }
                    this.DeSelectRoleEntity();
                }
                if (e.ClickButtomCoed == MouseButton.RightMouse && e.ClickPosition.ToVector3Int() != this.SelectRoleEntity.MoveComponent.CurrentRolePosition)
                {
                    this.DeSelectRoleEntity();
                }
            }
        }
Example #3
0
        private void RouteMapControl_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            var geoPoint   = args.Location;
            var clickedLat = geoPoint.Position.Latitude;

            clickedLat = Math.Round(clickedLat, 3);
            var clickedLong = geoPoint.Position.Longitude;

            clickedLong = Math.Round(clickedLong, 3);
            if (thisRoute.StartPosition.Point.Latitude.ToString().Contains(clickedLat.ToString()) && thisRoute.StartPosition.Point.Longitude.ToString().Contains(clickedLong.ToString()))
            {
                VisitSpeedBlock.Text = thisRoute.StartPosition.VisitSpeed.ToString();
                VisitTimeBlock.Text  = thisRoute.StartPosition.VisitedTime.ToString();
            }
            if (thisRoute.EndPosition.Point.Latitude.ToString().Contains(clickedLat.ToString()) && thisRoute.EndPosition.Point.Longitude.ToString().Contains(clickedLong.ToString()))
            {
                VisitSpeedBlock.Text = thisRoute.EndPosition.VisitSpeed.ToString();
                VisitTimeBlock.Text  = thisRoute.EndPosition.VisitedTime.ToString();
            }
            if (thisRoute.MarkedPositions != null)
            {
                foreach (var pos in thisRoute.MarkedPositions)
                {
                    if (pos.Point.Latitude.ToString().Contains(clickedLat.ToString()) && pos.Point.Longitude.ToString().Contains(clickedLong.ToString()))
                    {
                        VisitSpeedBlock.Text = pos.VisitSpeed.ToString();
                        VisitTimeBlock.Text  = pos.VisitedTime.ToString();
                    }
                }
            }
        }
Example #4
0
 private void map_MapHolding(MapControl sender, MapInputEventArgs args)
 {
     if (viewOfRoute != null)
     {
         map.Routes.Remove(viewOfRoute);
     }
 }
        private void OnMapClicked(MapControl sender, MapInputEventArgs args)
        {
            if (_iconClicked)
            {
                _iconClicked = false;
                return;
            }

            if (CloseWindows())
            {
                return;
            }

            if (_pins.Pins.WaypointsPin.Count == 8)
            {
                Application.Current.MainPage.DisplayAlert("Error", "You can`t add more then 8 waypoints", "Ok");
                return;
            }

            var pinAdd = new MapAddPin(args.Location.Position);

            pinAdd.TypeSelected += OnTypeSelected;
            var position = new BasicGeoposition
            {
                Latitude  = args.Location.Position.Latitude,
                Longitude = args.Location.Position.Longitude
            };

            AddWindow(pinAdd, position);
        }
Example #6
0
        /// <summary>
        /// The <c>MapTapped</c> method gets invoked, when the user taps on the <c>MapControl</c> provided by the <c>AddShop</c>-View.
        /// It gets the geographical position of the point, where the User tapped on the <c>MapControl</c>. With this position,
        /// the method estimates an address and saves the gathered values to its Properties (<c>Location</c> and <c>Address</c>).
        ///
        /// If there are no results for the address, the values for the Properties don't get set.
        /// </summary>
        /// <param name="sender">The <c>MapControl</c> provided by the View, which was tapped by the User.</param>
        /// <param name="args">Contains the geographical position of the point, where the User tapped on the <c>MapControl</c>.</param>
        public async void MapTapped(MapControl sender, MapInputEventArgs args)
        {
            try
            {
                // Set tapped Location as selected location
                Location = args.Location.Position;

                // Find corresponding address of the location
                MapLocationFinderResult FinderResult = await MapLocationFinder.FindLocationsAtAsync(args.Location);

                // Check, if any address has been found
                if (FinderResult.Status == MapLocationFinderStatus.Success && FinderResult.Locations.Count > 0)
                {
                    // Format and set address of the selected location
                    var    selectedLocation = FinderResult.Locations.First();
                    string format           = "{0} {1}, {2} {3}, {4}";

                    Address = string.Format(format,
                                            selectedLocation.Address.Street,
                                            selectedLocation.Address.StreetNumber,
                                            selectedLocation.Address.PostCode,
                                            selectedLocation.Address.Town,
                                            selectedLocation.Address.CountryCode);
                }
            }
            catch (Exception ex)
            {
                Address = string.Empty;
                dialogService.ShowMessage(
                    ResourceLoader.GetForCurrentView().GetString("FindAddressError"),
                    ResourceLoader.GetForCurrentView().GetString("ErrorTitle"));
            }
        }
Example #7
0
        public void HandleMapClicked(MapInputEventArgs args)
        {
            BasicGeoposition tappedGeoPosition = args.Location.Position;
            string           status            = "MapTapped at Latitude: " + tappedGeoPosition.Latitude + ", Longitude: " + tappedGeoPosition.Longitude;

            mainView.SetStatusText(status);
        }
Example #8
0
 private void Map_MapTapped(MapControl sender, MapInputEventArgs args)
 {
     if (isSomeAlarmSelected)
     {
         ZoomMap(boxToDisplay);
     }
 }
 private async void Map_MapTapped(MapControl sender, MapInputEventArgs args)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async delegate
     {
         if (fp == false)
         {
             TopLeft.Visibility = Visibility.Visible;
             TopLeftPos         = args.Location.Position;
             MapControl.SetLocation(TopLeft, args.Location);
             fp = true;
         }
         else
         {
             if (sp == false)
             {
                 BottomRight.Visibility = Visibility.Visible;
                 BottomRightPos         = args.Location.Position;
                 MapControl.SetLocation(BottomRight, args.Location);
                 sp = true;
                 DLButton.IsEnabled = true;
             }
             else
             {
                 await new MessageDialog(MultilingualHelpToolkit.GetString("MapDownloaderViewStringTwoPointsSelected", "Text")).ShowAsync();
             }
         }
     });
 }
 private void MapControl_MapHolding(MapControl sender, MapInputEventArgs args)
 {
     MapLongClicked?.Invoke(this, new MapClickedEventArgs(
                                new Position(args.Location.Position.Latitude,
                                             args.Location.Position.Longitude)
                                ));
 }
        private void MapControl_OnMapTapped(MapControl sender, MapInputEventArgs args)
        {
            if (PushPins.Count > 0)
            {
                MyMapControl.MapElements.Remove(PushPin.Icon);
                PushPins.Clear();
            }

            Geopoint location = args.Location; // Download the complete position of tapped point

            //DownloadedLocation = location;

            CheckBorders.Check(location);

            if (CheckBorders.Check(location) == true)
            {

                PushPin.SetPosition(MyMapControl, location.Position.Latitude, location.Position.Longitude);

                PushPins.Add(PushPin);
            }
            else
            {
                MessageBox.ShowMessage("Obszar poza zasięgiem!");
            }

            
        }
Example #12
0
 private void MyMap_MapTapped(MapControl sender, MapInputEventArgs args)
 {
     var tappedGeoPosition = args.Location.Position;
     var status = "MapTapped at \nLatitude:" + tappedGeoPosition.Latitude + "\nLongitude: " +
                  tappedGeoPosition.Longitude;
     //rootPage.NotifyUser(status, NotifyType.StatusMessage);
 }
Example #13
0
 private void mapTapped(object sender, MapInputEventArgs e)
 {
     eventGeopoint = new Geopoint(e.Location.Position);
     geoposition   = e.Location.Position;
     eEvents.Clear();
     eEvents.Add((new Common.Event(1, "", new User(""), new DateTime(2008, 1, 1, 1, 1, 1), new DateTime(2008, 1, 1, 1, 1, 1), geoposition.Latitude, geoposition.Longitude, "")));
 }
Example #14
0
 private void myMap_MapTapped_1(MapControl sender, MapInputEventArgs args)
 {
     Debug.WriteLine(args.Location);
     messageShown = false;
     pinOnMap = true;
     Controller.PinPosition = args.Location;
 }
Example #15
0
 void composedControl_MapTapped(MapControl sender, MapInputEventArgs e)
 {
     if (MapTapped != null)
     {
         MapTapped(sender, e.Position);
     }
 }
Example #16
0
 private void OnMapTapped(MapControl sender, MapInputEventArgs args)
 {
     viewModel.Locations.Add(new Location {
         Geopoint = args.Location
     });
     sender.Center = args.Location;
 }
 private async void Map_MapTapped(MapControl sender, MapInputEventArgs args)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async delegate
     {
         if (fp == false)
         {
             TopLeft.Visibility = Visibility.Visible;
             TopLeftPos         = args.Location.Position;
             MapControl.SetLocation(TopLeft, args.Location);
             fp = true;
         }
         else
         {
             if (sp == false)
             {
                 BottomRight.Visibility = Visibility.Visible;
                 BottomRightPos         = args.Location.Position;
                 MapControl.SetLocation(BottomRight, args.Location);
                 sp = true;
                 DLButton.IsEnabled = true;
             }
             else
             {
                 await new MessageDialog("You selected 2 points.").ShowAsync();
             }
         }
     });
 }
Example #18
0
 private void RoutePlanMapControl_OnMapTapped(MapControl sender, MapInputEventArgs args)
 {
     if (!_mapIconClicked)
     {
         _customerUserControl.Visibility = Visibility.Collapsed;
     }
     _mapIconClicked = false;
 }
        private async void mapControl_Maptapped(MapControl sender, MapInputEventArgs args)
        {
            AddIconToLocation(args.Location, "Position:" + indexPosition);
            indexPosition++;
            Geopoint startPoint = await Library.Position();

            ShowRouteOnMap(startPoint, args.Location);//draw path when you click on map
        }
Example #20
0
 private async void MapControl_MapTapped(MapControl sender, MapInputEventArgs args)
 {
     var    tappedGeoPosition = args.Location.Position;
     string status            = $"Map tapped at Latitude: {tappedGeoPosition.Latitude}" +
                                $"Longitude: {tappedGeoPosition.Longitude}";
     var messageDialog = new MessageDialog(status);
     await messageDialog.ShowAsync();
 }
        private async void myMap_MapDoubleTapped(MapControl sender, MapInputEventArgs args)
        {
            var uriSchool       = new Uri(@"bingmaps:? cp = 51.031359~-3.706420 & lvl = 15");
            var launcherOptions = new Windows.System.LauncherOptions();

            launcherOptions.TargetApplicationPackageFamilyName = "Microsoft.WindowsMaps_8wekyb3d8bbwe";
            var success = await Windows.System.Launcher.LaunchUriAsync(uriSchool, launcherOptions);
        }
Example #22
0
        private async void eCopyMapa_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            dodajIkonuNaPoziciju(args.Location, "Position: " + indexPosition);
            indexPosition++;
            Geopoint pocetak = await Library.Position();

            PrikaziRutu(pocetak, args.Location); //crtaj na klik
        }
Example #23
0
        private async void myMap_Tapped(MapControl sender, MapInputEventArgs args)
        {
            addIconToLocation(args.Location, "Position: " + indexPosition);
            indexPosition++;
            Geopoint startPoint = await Library.Position();

            ShowRouteOnMap(startPoint, args.Location);
        }
Example #24
0
 private async void ExecuteResetPosition(MapInputEventArgs args)
 {
     if (args != null)
     {
         MapCenter = args.Location;
         await CreateBusStops(args.Location.Position);
     }
 }
 private void _mapControl_MapTapped(MapControl sender, MapInputEventArgs args)
 {
     if (_mapTapped.HasValue && _draggedWaypoint != null && (DateTime.Now - _mapTapped).Value > TimeSpan.FromMilliseconds(100))
     {
         _draggedWaypoint = null;
         _mapTapped       = null;
     }
 }
 private void Map_MapTapped(MapControl sender, MapInputEventArgs args)
 {
     if (markerSeekiosOverlayShown)
     {
         Map.Children.Remove(_mapSeekiosMarkerOverlay);
         markerSeekiosOverlayShown = false;
     }
 }
Example #27
0
 private void MapTapped(MapControl sender, MapInputEventArgs args)
 {
     //Hide Expansion on Tapping on empty parts of map
     if (Pushpin.LastAnimatedPushpin != null)
     {
         Pushpin.LastAnimatedPushpin.HideExpansion();
     }
 }
Example #28
0
        //responds to holding map with left button or long press
        //adds a way point at the selected position and updates the map
        private void Map_MapHolding(MapControl sender, MapInputEventArgs args)
        {
            var latitude  = args.Location.Position.Latitude;
            var longitude = args.Location.Position.Longitude;

            _waypoints.Add(new WayPoint(latitude, longitude));

            UpdateMap();
        }
Example #29
0
 private void MapControl_MapTapped(MapControl sender, MapInputEventArgs args)
 {
     if (!_mapClickWasElementClick)
     {
         AddTmpMapPoint(args.Location);
         UpdateAddButtonsVisibility();
     }
     _mapClickWasElementClick = false;
 }
 /// <summary>
 /// Handles the MapTapped event.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">A <see cref="MapInputEventArgs"/> with arguments of the event.</param>
 private void OnMapTapped(MapControl sender, MapInputEventArgs e)
 {
     // If annotation exists
     if (this.annotation != null)
     {
         this.Control.Children.Remove(this.annotation);
         this.annotation = null;
     }
 }
Example #31
0
        private void MapControl_MapHolding(MapControl sender, MapInputEventArgs args)
        {
            MapControl.MapElements.Clear();
            MapIcon myIcon = new MapIcon {
                Location = args.Location, NormalizedAnchorPoint = new Point(1.0, 1.0), Title = "Event localisation", ZIndex = 0
            };

            MapControl.MapElements.Add(myIcon);
        }
Example #32
0
        private void mapLocation_MapDoubleTapped(MapControl sender, MapInputEventArgs args)
        {
            txtLatitude.Text  = args.Location.Position.Latitude.ToString();
            txtLongitude.Text = args.Location.Position.Longitude.ToString();

            if (StandardPopup.IsOpen)
            {
                StandardPopup.IsOpen = false;
            }
        }
Example #33
0
        /// <summary>
        /// Handles the Holding event of the MapControl to add a new location
        /// to the Locations list, using the position indicated by the gesture.
        /// </summary>
        private async void InputMap_MapHolding(MapControl sender, MapInputEventArgs args)
        {
            //var location = new LocationData { Position = args.Location.Position };

            //// Resolve the address given the geocoordinates. In this case, because the
            //// location is unambiguous, there is no need to pass in the current location.
            //await LocationHelper.TryUpdateMissingLocationInfoAsync(location, null);

            //this.EditNewLocation(location);
        }
Example #34
0
        void OnMapHolding(MapControl sender, MapInputEventArgs args)
        {
            // Get point were a landmark should be put

            // Show context menu
            FrameworkElement contextElement = spContextMenu as FrameworkElement;
            if (contextElement != null)
            {
                FlyoutBase flyoutBase = FlyoutBase.GetAttachedFlyout(contextElement);
                flyoutBase.ShowAt(contextElement);
            }
        }
Example #35
0
        private  void LocationMap_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            //MapIcon icon = new MapIcon();
            //icon.Location = args.Location;
            //icon.NormalizedAnchorPoint = new Point(0.5, 1.0);

            //MapLocationFinderResult result = await MapLocationFinder.FindLocationsAtAsync(args.Location);
            //if (result.Status == MapLocationFinderStatus.Success)
            //{
            //    icon.Title = result.Locations[0].Address.FormattedAddress;
            //}

            //LocationMap.MapElements.Clear();
            //LocationMap.MapElements.Add(icon);
        }
Example #36
0
        private void Map_Tapped(MapControl sender, MapInputEventArgs args)
        {
            if (!sender.IsEnabled)
                return;

            lat = args.Location.Position.Latitude;
            lon = args.Location.Position.Latitude;

            MapIcon icon = new MapIcon();
            icon.Location = args.Location;
            icon.Title = "";
            sender.MapElements.Clear();

            sender.MapElements.Add(icon);
        }
 private bool HomeTapped(MapInputEventArgs args)
 {
     if (HomePin != null)
     {
         Point pt = args.Position;
         Point homePos;
         double dx = 36 / 2;
         double dy = 36 / 2;
         myMap.GetOffsetFromLocation(HomePin.Location, out homePos);
         if (Math.Abs(homePos.X - pt.X) < dx && Math.Abs(homePos.Y - pt.Y) < dy)
         {
             return true;
         }
     }
     return false;
 }
        private void mymap_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            var pos = args.Location;
            BasicGeoposition bg = new BasicGeoposition
            {
                Latitude = Math.Round(pos.Position.Latitude,4),
                Longitude = Math.Round(pos.Position.Longitude,4)
            };

            
            getDataFromCloud(bg);

            
            

           // mymap.MapElements.Add(cP);
        }
        private async void MapControl_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            var userGeopoint = new Geopoint(new BasicGeoposition
            {
                Latitude = args.Location.Position.Latitude,
                Longitude = args.Location.Position.Longitude
            });

            var vm = this.DataContext as VehicleDetailViewModel;

            vm.ChangeCurrentPositionCommand.Execute(userGeopoint);

            // To avoid massive notifications events.
            if (_hubConnection.State == ConnectionState.Reconnecting)
                await Task.Delay(TimeSpan.FromSeconds(2));

            await _proxy.Invoke("UpdateEmployeePosition", CommonAppSettings.FixedEmployeeId, args.Location.Position.Latitude, args.Location.Position.Longitude);
        }
        private async void OnMapTapped(MapControl sender, MapInputEventArgs args)
        {
            Geopoint location = args.Location;
            
            if (MissionPin == null)
            {
                MissionPin = new MapIcon();
                StorageFolder installDir = Windows.ApplicationModel.Package.Current.InstalledLocation;
                StorageFile icon = await installDir.GetFileAsync(@"Assets\pin.png");
                MissionPin.Image = icon;
                myMap.MapElements.Add(MissionPin);
                MissionPin.NormalizedAnchorPoint = new Point(7/36, 32/36);
                MissionPin.Title = "";
            }
            ShowError(location.Position.Latitude + "," + location.Position.Longitude);
            MissionPin.Location = location;
//            locationSet = true;

            if (HomeTapped(args))
            {
                //simulation.RaiseEvent(SimulationMachine.P_MACHINE_GpsSensor, SimulationEvent.P_EVENT_GPS_HOME, null);
            }

        }
 private void Map_MapTapped(MapControl sender, MapInputEventArgs args)
 {
     if (isSomeAlarmSelected)
         ZoomMap(boxToDisplay);
 }
Example #42
0
 private void myMap_MapTapped_1(MapControl sender, MapInputEventArgs args)
 {
     Debug.WriteLine(args.Location);
     var mapIcon1 = new MapIcon();
     mapIcon1.Location = args.Location;
     mapIcon1.NormalizedAnchorPoint = new Point(0.5, 1.0);
     mapIcon1.Title = "My Friend";
     mapIcon1.Image = mapIconStreamReference;
     mapIcon1.ZIndex = 0;
     myMap.MapElements.Clear();
     myMap.MapElements.Add(mapIcon1);
 }
Example #43
0
        private async void Mymap_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            Geopoint pointToReverseGeocode = new Geopoint(args.Location.Position);

            //Mostra o local encontrado 
            MapLocationFinderResult result = await MapLocationFinder.FindLocationsAtAsync(pointToReverseGeocode);
            var resultText = new StringBuilder();

            if(result.Status == MapLocationFinderStatus.Success)
            {
                resultText.AppendLine(result.Locations[0].Address.Street + ", " + result.Locations[0].Address.Town + 
                     ", " + result.Locations[0].Address.Country);

            }
            Morada = resultText.ToString();
            MessageBox(resultText.ToString());
            this.Frame.Navigate(typeof(Addcontact), Morada);
           
        }
Example #44
0
 private void myMap_MapHolding(MapControl sender, MapInputEventArgs args)
 {
     Debug.WriteLine("!" + args.Location);
 }
        private async void mcShowLocation_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            // add the image
            addImageToMap(args.Location);

            // display the address
            await displayAddress(args.Location);
        }
        private void MapControl_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            //Close Venue Details popup if it oppened when clicking on map
            if (prev_pin != null)
                prev_pin.pin_background.Source = new BitmapImage(
                    new Uri("ms-appx:///Assets/icons/ico-venue.png", UriKind.RelativeOrAbsolute));

            //Popup Close Animation
            pu_close_anim.Begin();

            prev_pin = null;
        }
Example #47
0
 private void MapSet_MapTapped(MapControl sender, MapInputEventArgs args)
 {
     pin.Location = args.Location;
 }
        private void MapLocationsControl_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            foreach (var img in items)
            {
                if (img.image != "/Assets/ico-mylocation-pin.png")
                    img.image = "/Assets/ico-venue.png";

            }
            InfoBorder.Visibility = Visibility.Collapsed;
            TBname.Text = string.Empty;
            TBaddress.Text = string.Empty;
            TBdistance.Text = string.Empty;
            count.Text = string.Empty;
        }
Example #49
0
        private void OnMapTapped(MapControl sender, MapInputEventArgs args)
        {
            var icon = sender.FindMapElementsAtOffset(args.Position).OfType<MapIcon>().FirstOrDefault();

            if (icon != null)
            {
                CafeSummaryViewModel cafe;
                if (this.cafeMapIcons.TryGetValue(icon, out cafe))
                {
                    this.ViewModel.SelectCafe.Execute(cafe);
                }    
            }
        }
Example #50
0
        private async void MapTapped(MapControl sender, MapInputEventArgs e)
        {
            if (ifResultShown)
                button6_Click(sender, new RoutedEventArgs());
            /*
            var pos = e.Location
            var pos = e.GetPosition(myMap);
            Geopoint tmp = new Geopoint(location);
            myMap.GetLocationFromOffset(pos, out tmp);
            */

            location = e.Location.Position;
            Debug.WriteLine(location.Latitude);
            //myMap.SetView(location);

            string tmpSourseLoc = Convert.ToString(location.Latitude).Substring(0, Convert.ToString(location.Latitude).IndexOf(',')) + '.' + Convert.ToString(location.Latitude).Substring(Convert.ToString(location.Latitude).IndexOf(',') + 1, Convert.ToString(location.Latitude).Length - Convert.ToString(location.Latitude).IndexOf(',') - 1);
            tmpSourseLoc += "," + Convert.ToString(location.Longitude).Substring(0, Convert.ToString(location.Longitude).IndexOf(',')) + '.' + Convert.ToString(location.Longitude).Substring(Convert.ToString(location.Longitude).IndexOf(',') + 1, Convert.ToString(location.Longitude).Length - Convert.ToString(location.Longitude).IndexOf(',') - 1);
            string address = "http://geocode-maps.yandex.ru/1.x/?geocode=" + tmpSourseLoc+ "&sco=latlong";
            log1.Text += address;
            StorageFile myDB;
            try
            {
               StorageFile tempFile2 = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync("multi", CreationCollisionOption.ReplaceExisting);
                BackgroundDownloader manager2 = new BackgroundDownloader();
                var operation = manager2.CreateDownload(new Uri(address), tempFile2);
                IProgress<DownloadOperation> progressH = new Progress<DownloadOperation>((p) =>
                { Debug.WriteLine("Transferred: {0}, Total: {1}", p.Progress.BytesReceived, p.Progress.TotalBytesToReceive); });
                await operation.StartAsync().AsTask(progressH);
                Debug.WriteLine("BacgroundTransfer created");

                myDB = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("multi");

                var alldata = await Windows.Storage.FileIO.ReadLinesAsync(myDB);
                datalines = new string[alldata.Count];
                int ko = 0; int start;
                foreach (var line in alldata)
                {
                    datalines[ko] = line.ToString();
                    ko++;
                    if ((start = datalines[ko - 1].IndexOf("<text>")) != -1)
                    {
                        int nameLeng = datalines[ko - 1].Length;
                        if (!isSourseTapped) sourseLable.Text = datalines[ko - 1].Substring(start + 6, nameLeng - 6 - start - 7);
                        else aimLable.Text = datalines[ko - 1].Substring(start + 6, nameLeng - 6 - start - 7);
                        break;
                    }
                }
                await myDB.DeleteAsync();
            }
            catch 
            {
                MessageDialog dialog = new MessageDialog("Мы не смогли обнаружить ничего рядом с данной меткой. Однако вы все равно можете попробовать построить маршрут, используя её.", "Ничего не найдено!");
            }

            if (!isSourseTapped)
            {
                myMap.Children.Clear();
                //myMap.ShapeLayers.Clear();
                myMap.Children.Add(pin);
                MapControl.SetLocation(pin, new Geopoint(location));
                //Bing.Maps.MapLayer.SetPosition(pin, location);
                sourseLocation = location;
                isSourseTapped = true;
                tipLable.Text = "Введите или выберите на карте конечную точку маршрута:";
                sourseLable.Visibility = Visibility.Visible;
                sourseLableBG.Visibility = Visibility.Visible;
                sourseLableHead.Visibility = Visibility.Visible;
                aimLable.Visibility = Visibility.Collapsed;
                aimLableBG.Visibility = Visibility.Collapsed;
                aimLableHead.Visibility = Visibility.Collapsed;
            }
            else
            {

                //Bing.Maps.MapLayer.SetPosition(pinAim, location);
                MapControl.SetLocation(pinAim, new Geopoint(location));
                AimLocation = location;
                myMap.Children.Add(pinAim);
                //isSourseTapped = true;
                await countingPerform();
                if (flagdistance)
                    await DrawPath();
                else
                {
                    MessageDialog dialog = new MessageDialog("Такое расстояние легче преодолеть на самолете", "Такси?");
                    await dialog.ShowAsync();
                }
                isSourseTapped = false;

                sourseLable.Visibility = Visibility.Visible;
                sourseLableBG.Visibility = Visibility.Visible;
                sourseLableHead.Visibility = Visibility.Visible;
                aimLable.Visibility = Visibility.Visible;
                aimLableBG.Visibility = Visibility.Visible;
                aimLableHead.Visibility = Visibility.Visible;

                getResult();
            }
        }
		private async void MyMap_MapTapped(MapControl sender, MapInputEventArgs args)
		{
			List<BusStop> startStopList;
			List<BusStop> endStopList;

			var resultText = new StringBuilder();
			resultText.AppendLine(string.Format("Position={0},{1}", args.Position.X, args.Position.Y));
			resultText.AppendLine(string.Format("Location={0:F9},{1:F9}", args.Location.Position.Latitude, args.Location.Position.Longitude));

			foreach (var mapObject in sender.FindMapElementsAtOffset(args.Position))
			{
				//resultText.AppendLine("Found: " + mapObject.ReadData<PointList>().Name);
			}
			//MessageDialogHelper.Show(resultText.Tostring(), "");

			if (wayPoints1 == null)
			{
				wayPoints1 = new Geopoint(new BasicGeoposition { Latitude = args.Location.Position.Latitude, Longitude = args.Location.Position.Longitude });
				MessageDialogHelper.Show("Chọn điểm đến", "");
			}
			else if (wayPoints2 == null)
			{
				wayPoints2 = new Geopoint(new BasicGeoposition { Latitude = args.Location.Position.Latitude, Longitude = args.Location.Position.Longitude });

				try
				{
					startStopList = findNearbyBusStop(wayPoints1, MyConstants.RADIUS);
					endStopList = findNearbyBusStop(wayPoints2, MyConstants.RADIUS);
					List<List<BusNode>> foundAnswerList = new List<List<BusNode>>();
					foreach (BusStop ss in startStopList)
					{
						foreach (BusStop es in endStopList)
						{
							// Begin Algorithm
							AStarAlgo AS1 = new AStarAlgo(ss, es);
							AS1.algorithm();
							if (AS1.answer.Count() != 0)
							{
								// We found an answer
								foundAnswerList.Add(AS1.answer);
							}							
						}
					}

					foreach(List<BusNode> ans in foundAnswerList)
					{
						// print to map
						/*
						for (int i = 0; i < foundAnswer.Count(); i++)
						{
							findShortestRoute(SampleDataSource.FindBusStopByCode(foundAnswer[i].stopCode).geo,
								SampleDataSource.FindBusStopByCode(foundAnswer[i + 1].stopCode).geo);
						}
						*/
						// print to string
						string detail = AStarResultToString(ans);
					}
					
				}
				catch (Exception exc)
				{
					string msg = exc.Message;
				}
				wayPoints2 = null;
				wayPoints1 = null;
			}
		}
Example #52
0
        async private void maperino_Tapped(MapControl sender, MapInputEventArgs e)
        {
            string COUNTRY = "Asukoht pole saadaval";
            if (isDone == true)
            {
                isDone = false;
            mapTappedPoint = e.Location;
            MapLocationFinderResult result = await MapLocationFinder.FindLocationsAtAsync(e.Location);
            var pin = new Grid()
            {
                Width = 25,
                Height = 25,
                Margin = new Windows.UI.Xaml.Thickness(-12)
            };

            pin.Children.Add(new Ellipse()
            {
                Fill = new SolidColorBrush(Colors.DodgerBlue),
                Stroke = new SolidColorBrush(Colors.White),
                StrokeThickness = 3,
                Width = 25,
                Height = 25
            });
            maperino.Children.Clear();

            MapControl.SetLocation(pin, new Geopoint(e.Location.Position));
            maperino.Children.Add(pin);
                string msgBox1;
            if (result.Locations.Count != 0 && result.Locations[0].Address.Country != "")
            {
                COUNTRY = result.Locations[0].Address.Country;
                if (result.Locations[0].Address.Town != "")
                {
                    COUNTRY += ", " + result.Locations[0].Address.Town;
                }
                    msgBox1 = "Do you want to add a note at " + COUNTRY + "?";
                }
            else
                {
                    msgBox1 = "Asukoht pole saadaval";
                }
                MessageDialog msgbox = new MessageDialog(msgBox1);
            msgbox.Commands.Add(new UICommand("Add", new UICommandInvokedHandler(this.CommandInvokedHandler)));
            msgbox.Commands.Add(new UICommand("Cancel", new UICommandInvokedHandler(this.CommandInvokedHandler)));
            await msgbox.ShowAsync();
                isDone = true;
            }
        }
 public void OnMapTapped(MapControl sender, MapInputEventArgs args)
 {
     CurrentPosition = args.Location;
 }
        private async void MapControl_OnMapTapped(MapControl sender, MapInputEventArgs args)
        {
            UserGeopoint = new Geopoint(new BasicGeoposition
            {
                Latitude = args.Location.Position.Latitude,
                Longitude = args.Location.Position.Longitude
            });

            // To avoid massive notifications events.
            if(_hubConnection.State == ConnectionState.Reconnecting)
                await Task.Delay(TimeSpan.FromSeconds(2));

            await _proxy.Invoke("UpdateEmployeePosition", CommonAppSettings.FixedEmployeeId, args.Location.Position.Latitude, args.Location.Position.Longitude);
        }
Example #55
0
    //MapTapped - not Map.Tapped!!
    private async void MyMap_MapTapped(MapControl sender, MapInputEventArgs args)
    {
      var resultText = new StringBuilder();
      resultText.AppendLine(string.Format("Position={0},{1}", args.Position.X, args.Position.Y));
      resultText.AppendLine(string.Format("Location={0:F9},{1:F9}", args.Location.Position.Latitude, args.Location.Position.Longitude));

      foreach( var mapObject in sender.FindMapElementsAtOffset(args.Position))
      {
        resultText.AppendLine("Found: " + mapObject.ReadData<PointList>().Name);
      }
      var dialog = new MessageDialog(resultText.ToString());
      await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => await dialog.ShowAsync());
    }
Example #56
0
        private void myMap_MapTapped(MapControl sender, MapInputEventArgs args)
        {

        }
Example #57
0
        private async void editMapTapped(MapControl sender, MapInputEventArgs args)
        {
            var dialog = new Windows.UI.Popups.MessageDialog("Agregar este lugar");
            dialog.Commands.Add(new Windows.UI.Popups.UICommand("Aceptar") { Id = 1 });
            dialog.Commands.Add(new Windows.UI.Popups.UICommand("Cancelar") { Id = 0 });
            var result = await dialog.ShowAsync();

            if (result.Id.Equals(1))
            {
                var res = await contentDialog.ShowAsync();

                edtProgressRing.IsActive = true;
                BasicGeoposition pos = new BasicGeoposition() { Latitude = args.Location.Position.Latitude, Longitude = args.Location.Position.Longitude }; ;
                Geopoint point = new Geopoint(pos);

                MapLocationFinderResult LocationAdress = await MapLocationFinder.FindLocationsAtAsync(point);
                direccion = LocationAdress.Locations[0].Address.Street + "-" + LocationAdress.Locations[0].Address.StreetNumber + ", "
                               + LocationAdress.Locations[0].Address.Country + ", " + LocationAdress.Locations[0].Address.Town;


                MapIcon mapIcon = new MapIcon();
                mapIcon.Location = point;
                mapIcon.NormalizedAnchorPoint = new Point(0.5, 1.0);
                mapIcon.Title = titulo_lugar + " - " + direccion;
                mapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/bus.png"));
                mapIcon.ZIndex = 0;

                editMap.MapElements.Add(mapIcon);
                edtProgressRing.IsActive = false;
            }
        }
        /// <summary>
        /// Handles the Holding event of the MapControl to add a new location
        /// to the Locations list, using the position indicated by the gesture.
        /// </summary>
        private async void InputMap_MapHolding(MapControl sender, MapInputEventArgs args)
        {
            var location = new LocationData { Position = args.Location.Position };

            // Resolve the address given the geocoordinates. In this case, because the 
            // location is unambiguous, there is no need to pass in the current location.
            await LocationHelper.TryUpdateMissingLocationInfoAsync(location, null);

            this.EditNewLocation(location);
        }
        /// <summary>
        /// Handles the Tapped event of the map control to reposition a location 
        /// when map selection mode is enabled.
        /// </summary>
        private async void InputMap_MapTapped(MapControl sender, MapInputEventArgs args)
        {
            this.InputMap.Routes.Clear();
            this.isExistingLocationBeingRepositioned = true;
            this.locationInEditOriginalPosition = this.locationInEdit.Position;
            this.locationInEdit.Position = args.Location.Position;

            var element = this.GetTemplateRootForLocation(this.locationInEdit);
            var flyout = Flyout.GetAttachedFlyout(element) as Flyout;
            var location = (flyout.Content as FrameworkElement).DataContext as LocationData;

            location.Position = args.Location.Position;
            location.Address = String.Empty;
            await LocationHelper.TryUpdateMissingLocationInfoAsync(location, null);

            this.DisableMapSelection();
            flyout.ShowAt(element);
        }
Example #60
0
 private void map_MapHolding(MapControl sender, MapInputEventArgs args)
 {
     if (viewOfRoute != null)
     {
         map.Routes.Remove(viewOfRoute);
     }
 }