예제 #1
0
        void InitializeMapData()
        {
            _geolocator = new Geolocator();
            FMobject = new FillModel();
            DMobject = new DataModel();
            POMobject = new PoliceOfficeModel();
            routeLayer = new MapShapeLayer();
            myMap.ShapeLayers.Add(routeLayer);
            FMobject.FillingModel();
            LV_POList.ItemsSource = FMobject.GovernrateList[0].POfficeList;

            var loc = new Bing.Maps.Location(29.837452, 31.362296);
            myMap.Center = loc;
            myMap.ZoomLevel = 6;
        }
예제 #2
0
        public async void getTheNear()
        {
            try
            {
                // Get my current  location on the map 
                Geolocator myGeolocator = new Geolocator();
                Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();
                Code.DataModel DMobject = new Code.DataModel();
                Code.PoliceOfficeModel POMobject = new Code.PoliceOfficeModel();
                Code.FillModel FMobject = new Code.FillModel();
                FMobject.FillingModel();
                containerList = new List<double>();
                List<Code.PoliceOfficeModel> TempList = new List<Code.PoliceOfficeModel>();

                for (int i = 0; i < (FMobject.GovernrateList.Count - 1); i++)
                {
                    for (int j = 0; j < (FMobject.GovernrateList[i].POfficeList.Count - 1); j++)
                    {
                        //containerList.Add(GetDistanceBetweenPoints(30.077014, 31.019178,
                        //    FMobject.GovernrateList[i].POfficeList[j].Latitude, FMobject.GovernrateList[i].POfficeList[j].Longitude));

                        //containerList.Add(GetDistanceBetweenPoints(myGeoposition.Coordinate.Latitude, myGeoposition.Coordinate.Longitude,
                        //    FMobject.GovernrateList[i].POfficeList[j].Latitude, FMobject.GovernrateList[i].POfficeList[j].Longitude));


                        containerList.Add(CalculateDistance(myGeoposition.Coordinate.Latitude, myGeoposition.Coordinate.Longitude,
                           FMobject.GovernrateList[i].POfficeList[j].Latitude, FMobject.GovernrateList[i].POfficeList[j].Longitude));




                        TempList.Add(new Code.PoliceOfficeModel()
                        {
                            Latitude = FMobject.GovernrateList[i].POfficeList[j].Latitude,
                            Longitude = FMobject.GovernrateList[i].POfficeList[j].Longitude,
                            OfficeName = FMobject.GovernrateList[i].POfficeList[j].OfficeName
                        });
                    }
                }


                //#region Searching Algorithm
                myLat = myGeoposition.Coordinate.Latitude;
                myLong = myGeoposition.Coordinate.Longitude;

                double tttt = containerList.Min();
                int kk = 0;
                for (; ; kk++)
                {
                    if (tttt == containerList[kk])
                    {
                        break;
                    }
                }

                double _long = 0, _lat = 0;
                double min = containerList[0];
                double last = containerList[containerList.Count - 1];


                _lat = TempList[kk].Latitude;
                _long = TempList[kk].Longitude;
                _officeName = TempList[kk].OfficeName;

                _distance = tttt;


                t1 = _lat;
                t2 = _long;
                DrawRoute(t1, t2);


            }

            catch { }
        }