コード例 #1
0
 public MapServices(Map map, Uri uri)
 {
   _routeLayer = new MapShapeLayer();
   _mapTrucks = map;
   _mapTrucks.ShapeLayers.Add(_routeLayer);
   _baseUri = uri;
 }
コード例 #2
0
        public BingMapsView()
        {
            this.InitializeComponent();

            routeLayer = new MapShapeLayer();
            MyMap.ShapeLayers.Add(routeLayer);
        }
コード例 #3
0
 void MyMap_Tapped(object sender, TappedRoutedEventArgs e)
 {
     var pos = e.GetPosition(MyMap);
     Bing.Maps.Location location = new Bing.Maps.Location();
     miniTockeShapeLayer = new MapShapeLayer();
     MyMap.TryPixelToLocation(pos, out location);
     GetAddressByLocation(location);
     locationCollection.Add(location);
 }
コード例 #4
0
        // Delegate methods
        internal PolylineManager(Map map)
        {
            this.map = map;

            polylines = new Dictionary<IMapPolyline, MapPolyline>();

            // Layer to hold the polylines
            polylinesLayer = new MapShapeLayer();
            map.ShapeLayers.Add(polylinesLayer);
        }
コード例 #5
0
        private async void LoadMap()
        {
            this.BingMap.Credentials = this.BingAPIKey;
            this.BingMap.MapType = Bing.Maps.MapType.Road;

            // Add shape layer to the map
            this.shapeLayer = new MapShapeLayer();
            this.BingMap.ShapeLayers.Add(this.shapeLayer);
            await this.RefreshMap();
            this.DrawBuffer();
        }
コード例 #6
0
        private MapShapeLayer CreateMapShapeLayer(Location startLocation, Location endLocation)
        {
            MapShapeLayer shapeLayer = new MapShapeLayer();
            MapPolyline polyline = new MapPolyline();

            polyline.Locations = new LocationCollection { startLocation, endLocation };
            polyline.Color = Color.FromArgb(255,255,120,56);
            polyline.Width = 10;

            shapeLayer.Shapes.Add(polyline);
            mainMap.ShapeLayers.Add(shapeLayer);

            return shapeLayer;
        }
コード例 #7
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;
        }
コード例 #8
0
        private void CreateButton_Click(object sender, RoutedEventArgs e)
        {
            if (locationCollection.Count > 0)
            {
                //ClearMap();

                MapShapeLayer shapeLayer = new MapShapeLayer();

                MapPolygon polygon = new MapPolygon();
                polygon.FillColor = Windows.UI.Colors.Blue;
                polygon.Locations = locationCollection;
                shapeLayer.Shapes.Add(polygon);
                MyMap.ShapeLayers.Add(shapeLayer);
            }
        }
コード例 #9
0
        async void loader_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (String.Equals(e.PropertyName, "ArmedFences") || String.Equals(e.PropertyName, "TriggerFence"))
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    List<Geofence> result = loader.ArmedFences;

                    // Add application fences
                    MapShapeLayer fences = new MapShapeLayer();
                    MapLayer pushpins = new MapLayer();
                    foreach (Geofence f in result)
                    {
                        Geocircle c1 = f.Geoshape as Geocircle;
                        MapPolyline fence = new MapPolyline();
                        fence.Color = Colors.Red;
                        fence.Width = 5;
                        fence.Locations = DrawMapsCircle(c1.Center, c1.Radius);
                        fences.Shapes.Add(fence);

                        Pushpin p = new Pushpin();
                        p.Background = new SolidColorBrush(Colors.Red);
                        ToolTipService.SetToolTip(p, f.Id);
                        MapLayer.SetPosition(p, new Location(c1.Center.Latitude, c1.Center.Longitude));
                        pushpins.Children.Add(p);
                    }

                    // Add trigger fence
                    Geocircle c2 = loader.TriggerFence.Geoshape as Geocircle;
                    MapPolyline trigger = new MapPolyline();
                    trigger.Color = Colors.Gray;
                    trigger.Width = 5;
                    trigger.Locations = DrawMapsCircle(c2.Center, c2.Radius);
                    fences.Shapes.Add(trigger);

                    myMap.ShapeLayers.Clear();
                    myMap.ShapeLayers.Add(fences);

                    // Clear existing pushpins
                    var existingLayers = myMap.Children.Where(c => c is MapLayer).ToArray();
                    for (int i = 0; i < existingLayers.Count(); i++)
                    {
                        myMap.Children.Remove(existingLayers[i]);
                    }
                    myMap.Children.Add(pushpins);
                });
            }
        }
コード例 #10
0
ファイル: MainPage.xaml.cs プロジェクト: rvnijnatten/WeBreda
        public void drawRouteLine(List<WeBreda.Model.Waypoint> wpList)
        {
            Map.ShapeLayers.Remove(shapeLayer);
            shapeLayer = new MapShapeLayer();
            MapPolyline polyLine = new MapPolyline();
            polyLine.Color = Windows.UI.Colors.Red;
            polyLine.Width = 5;

            foreach (WeBreda.Model.Waypoint wp in wpList)
            {
                polyLine.Locations.Add(new Location()
                {
                    Latitude = wp.Latitude,
                    Longitude = wp.Longitude
                });
            }
            shapeLayer.Shapes.Add(polyLine);
            Map.ShapeLayers.Add(shapeLayer);
        }
コード例 #11
0
        /// <summary>
        /// Change the polylines on the map.
        /// </summary>
        private static void ShapesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MapControl mapControl = (MapControl)d;

            if (e.OldValue != null)
            {
                // remove all old polylines from the map:
                mapControl.map.ShapeLayers.Clear();
            }

            if (e.NewValue != null)
            {
                MapShapeLayer routeLayer = new MapShapeLayer();

                List<Shape> shapes = (List<Shape>)e.NewValue;
                foreach (var shape in shapes)
                {
                    MapPolyline polyline = new MapPolyline();
                    polyline.Color = Color.FromArgb(255, 0x4f, 0x64, 0xba);
                    polyline.Width = 6;

                    LocationCollection locations = new LocationCollection();
                    foreach (var point in shape.Points)
                    {
                        locations.Add(new Location(point.Latitude, point.Longitude));
                    }

                    polyline.Locations = locations;
                    routeLayer.Shapes.Add(polyline);
                }

                mapControl.map.ShapeLayers.Add(routeLayer);
            }
        }
コード例 #12
0
 private void DrawRoute(LocationCollection wayPoints)
 {
     MapShapeLayer shapeLayer = new MapShapeLayer();
     MapPolyline polyline = new MapPolyline();
     polyline.Locations = wayPoints;
     polyline.Color = Windows.UI.Colors.Red;
     polyline.Width = 5;
     shapeLayer.Shapes.Add(polyline);
     LocationRect mapRectangle = new LocationRect(wayPoints);
     this.map.SetView(mapRectangle);
     this.map.ShapeLayers.Add(shapeLayer);
 }
コード例 #13
0
 private void AppBarButton_getNearest(object sender, RoutedEventArgs e)
 {
     ClearMap();
     routeLayer = new MapShapeLayer();
     myMap.ShapeLayers.Add(routeLayer);
     getTheNear();
 }
コード例 #14
0
ファイル: UsefulCrap.cs プロジェクト: JorgeCupi/SmartGuard
        public static async void GetDirections(Map myMap, Border RouteResults)
        {
            MapShapeLayer routeLayer = new MapShapeLayer();
            myMap.ShapeLayers.Add(routeLayer);

            Uri routeRequest = new Uri(string.Format(
                "http://dev.virtualearth.net/REST/V1/Routes/Driving?wp.0={0},{1}&wp.1={2},{3}&rpo=Points&key={4}", staticObjects.CurrentLatitude, staticObjects.CurrentLongitude, staticObjects.GoalLatitude, staticObjects.GoalLongitude, myMap.Credentials));

            //Make a request and get the response
            Response r = await GetResponse(routeRequest);

            if (r != null &&
                r.ResourceSets != null &&
                r.ResourceSets.Length > 0 &&
                r.ResourceSets[0].Resources != null &&
                r.ResourceSets[0].Resources.Length > 0)
            {
                Route route = r.ResourceSets[0].Resources[0] as Route;

                //Get the route line data
                double[][] routePath = route.RoutePath.Line.Coordinates;
                LocationCollection locations = new LocationCollection();

                for (int i = 0; i < routePath.Length; i++)
                {
                    if (routePath[i].Length >= 2)
                    {
                        locations.Add(new Bing.Maps.Location(routePath[i][0],
                                        routePath[i][1]));
                    }
                }

                MapPolyline routeLine = new MapPolyline()
                {
                    Color = Colors.Indigo,
                    Locations = locations,
                    Width = 7
                };

                routeLayer.Shapes.Add(routeLine);

                BitmapImage srcStart = new BitmapImage();
                srcStart.UriSource = new Uri(App.fbProfilePicture, UriKind.Absolute);
                ImageBrush imgStart = new ImageBrush();
                imgStart.ImageSource = srcStart;
                Ellipse start = new Ellipse() { Fill = imgStart, Height = 70, Width = 70 };

                myMap.Children.Add(start);
                MapLayer.SetPosition(start,
                    new Bing.Maps.Location(route.RouteLegs[0].ActualStart.Coordinates[0],
                        route.RouteLegs[0].ActualStart.Coordinates[1]));

                BitmapImage srcEnd = new BitmapImage();
                srcEnd.UriSource = staticObjects.FriendProfilePicture;
                ImageBrush imgEnd = new ImageBrush();
                imgEnd.ImageSource = srcEnd;
                Ellipse end = new Ellipse() { Fill = imgEnd, Height = 70, Width = 70 };

                myMap.Children.Add(end);
                MapLayer.SetPosition(end,
                    new Bing.Maps.Location(route.RouteLegs[0].ActualEnd.Coordinates[0],
                    route.RouteLegs[0].ActualEnd.Coordinates[1]));

                myMap.SetView(new LocationRect(locations));
                RouteResults.DataContext = route;
            }
        }
コード例 #15
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="points"></param>
        private void DrawRoute(List<Location> points)
        {
            MapShapeLayer shapeLayer = new MapShapeLayer();
            MapPolyline polyline = new MapPolyline();

            LocationCollection lc = new LocationCollection();

            foreach (Location p in points)
            {
                lc.Add(p);
            }

            polyline.Locations = lc;
            polyline.Color = Color.FromArgb(255, 102, 0, 0);
            polyline.Width = 5;
            shapeLayer.Shapes.Add(polyline);
            Map.ShapeLayers.Clear();
            Map.ShapeLayers.Add(shapeLayer);

            Location midpoint = new Location(lc.FirstOrDefault().Latitude + ((lc.LastOrDefault().Latitude - lc.FirstOrDefault().Latitude) / 2.0),
                                             lc.FirstOrDefault().Longitude + ((lc.LastOrDefault().Longitude - lc.FirstOrDefault().Longitude) / 2.0));

            Map.SetView(midpoint, 15.5F);
        }
コード例 #16
0
 public async void DrawRoute(double lat, double lon, string falg)
 {
     //try
     //{
     string point2 = "";
     Geolocator myGeolocator = new Geolocator();
     Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();
     string point1 = myGeoposition.Coordinate.Latitude + "," + myGeoposition.Coordinate.Longitude;
     GetCurrentLocation();
     point2 = lat + "," + lon;
     string reqURL = "http://dev.virtualearth.net/REST/V1/Routes?wp.0=" + point1 + "&wp.1=" + point2 + "&key=AgGh6rnsoa0ho6TQLJ2Sm-gVwIRzUmxnB2MkNdEiglFsJsfXxqBFZkKdetZFyY7q";
     HttpClient client = new HttpClient();
     HttpResponseMessage response = await client.GetAsync(new Uri(reqURL));
     var jsonResponse = await response.Content.ReadAsStringAsync();
     var rootObject = JsonConvert.DeserializeObject<RootObject>(jsonResponse);
     foreach (ResourceSet set in rootObject.resourceSets)
     {
         resourceSet.Add(set);
     }
     loc.Clear();
     resource = resourceSet[0].resources[0];
     items = resource.routeLegs[0].itineraryItems;
     // Colleting location points to draw route got in response. 
     foreach (ItineraryItem item in items)
     {
         loc.Add(new Location() { Latitude = item.maneuverPoint.coordinates[0], Longitude = item.maneuverPoint.coordinates[1] });
     }
     // Declaring Object of MapPolyline to Draw Route
     MapPolyline line;
     line = new MapPolyline();
     // Defining color to Polyline that is Red you can give any color to it. 
     if (falg == "0")
         line.Color = Colors.Red;
     else if (falg == "1")
         line.Color = Colors.Black;
     // Defining width of Polyline so it can easily be visible to naked eye. 
     line.Width = 5;
     // Giving Collection of location points to Map Polyline     
     foreach (Location l in loc)
     {
         line.Locations.Add(l);
     }
     // Defining Map Shape layer Object to add Polyline shape to it. 
     shapeLayer = new MapShapeLayer();
     // Adding line to Shape Layer 
     shapeLayer.Shapes.Add(line);
     // Adding Shape Layer to Map
     MyMap.ShapeLayers.Add(shapeLayer);
     // Calculating Mid between both location to set center of Map
     int mid;
     if (loc.Count % 2 == 0)
     {
         mid = loc.Count / 2;
     }
     else
     {
         mid = (loc.Count + 1) / 2;
     }
     // Setting center of Map to Middle of Both Locations
     MyMap.Center = loc[mid];
     // Setting ZoomLevel of Map
     MyMap.ZoomLevel = 14;
     //}
     //catch (Exception ex)
     //{
     //    Debug.WriteLine(ex.ToString());
     //}
     //finally
     //{
     //  //  drawroute.IsEnabled = true;
     //   // progress.Visibility = Visibility.Collapsed;
     //}
 }
コード例 #17
0
        private void MyMap_OnLoaded(object sender, RoutedEventArgs e)
        {
            var map = (Bing.Maps.Map) sender;
            var mapShapeLayer = new MapShapeLayer();
            var polyLine = new MapPolyline();

            var activities = map.Tag as List<Activity>;
            if (activities == null)
                return;

            var pinNumber = 0;
            foreach (var activity in activities
                .GroupBy(x => x.Latitude + x.Longitude) //ignore dupe coordinates
                .Select(g => g.First())
                .OrderBy(x => x.Timestamp))
            {
                // ReSharper disable CompareOfFloatsByEqualityOperator
                if (activity.Latitude != 0 && activity.Longitude != 0)
                {
                    polyLine.Locations.Add(new Location(activity.Latitude, activity.Longitude));

                    pinNumber++;
                    var pin = new Pushpin();
                    pin.Text = pinNumber.ToString();
                    pin.FontSize = 13; //this size works good for single or double digits
                    
                    MapLayer.SetPosition(pin, new Location(activity.Latitude, activity.Longitude));
                    map.Children.Add(pin);
                }
                // ReSharper restore CompareOfFloatsByEqualityOperator
            }
            
            polyLine.Width = 3;
            mapShapeLayer.Shapes.Add(polyLine);
            map.ShapeLayers.Add(mapShapeLayer);

            //Calculate a bounding box for the route
            var t = activities.Where(x => x.Latitude != 0).Max(x => x.Latitude);
            var b = activities.Where(x => x.Latitude != 0).Min(x => x.Latitude);
            var l = activities.Where(x => x.Longitude != 0).Min(x => x.Longitude);
            var r = activities.Where(x => x.Longitude != 0).Max(x => x.Longitude);

            //Pad the box
            var latPad = (t - b)*.3;
            var longPad = (r - l)*.3;
            
            map.SetView(new LocationRect(new Location(t + latPad,l-longPad), new Location(b - latPad,r + longPad)), MapAnimationDuration.None);
        }
コード例 #18
0
ファイル: MapView.xaml.cs プロジェクト: Tmutsaers/HierInBreda
        public async void createRouteToVVV(Bing.Maps.Location curLoc,Bing.Maps.Location vvvLoc)
        {
            try
            {
                foreach (MapShapeLayer layer in Map.ShapeLayers)
                {
                    if (layer.Equals(RouteLayer))
                    {
                        layer.Shapes.Clear();
                        RouteLayer.Shapes.Clear();
                    }
                }
                Map.ShapeLayers.Clear();

                WaypointCollection routePoints = new WaypointCollection { new Waypoint(curLoc), new Waypoint(vvvLoc) };
                DirectionsManager manager = Map.DirectionsManager;
                manager.Waypoints.Clear();
                manager.RequestOptions.RouteMode = RouteModeOption.Walking;
                manager.Waypoints = routePoints;
                manager.RenderOptions.WalkingPolylineOptions.Visible = true;

                RouteResponse resp = await manager.CalculateDirectionsAsync();
                resp.Routes[0].RoutePath.LineWidth = 10.0;
                resp.Routes[0].RoutePath.LineColor = new Windows.UI.Color { A = 200, R = 200, B = 0, G = 2 };
                MapShapeLayer layer10 = new MapShapeLayer();
                
                

                LocationCollection locs = new LocationCollection();
                foreach(Bing.Maps.Location l in resp.Routes[0].RoutePath.PathPoints)
                {
                    Pushpin p = new Pushpin();
                    p.Text = "Pin";
                    MapLayer.SetPosition(p, l);
                    Map.Children.Add(p);
                    locs.Add(l);
                }
                MapPolyline line = new MapPolyline { Locations = locs };
                line.Color = new Windows.UI.Color { A = 100, G = 0, B = 200, R = 0 };
                line.Visible = true;
                line.Width = 10.0;
                layer10.Shapes.Add(line);
                Map.ShapeLayers.Add(layer10);

                manager.ShowRoutePath(resp.Routes[0]);
            }
            catch(Exception d)
            {
                System.Diagnostics.Debug.WriteLine(d);
                showInternetPopup();
            }
        }
コード例 #19
0
ファイル: MapPage.xaml.cs プロジェクト: EmiiFont/MyShuttle_RC
        private async void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var shapeLayer = MainMap.ShapeLayers.FirstOrDefault();
            if (shapeLayer == null)
            {
                shapeLayer = new MapShapeLayer();
                MainMap.ShapeLayers.Add(shapeLayer);
            }

            foreach (var routeViewModel in e.RemovedItems.Cast<RouteViewModel>())
            {
                var item = routes[routeViewModel];
                if (item != null)
                {
                    shapeLayer.Shapes.Remove(item.Item2);
                    MainMap.Children.Remove(item.Item1);
                    MainMap.Children.Remove(item.Item3);
                }

            }

            foreach (var routeViewModel in e.AddedItems.Cast<RouteViewModel>())
            {
                var pushpin1 = new Pushpin
                {
                    Background = new SolidColorBrush(Colors.White)
                };
                MapLayer.SetPosition(pushpin1, routeViewModel.Locations.First());
                var routeLine = new MapPolyline();
                routeLine.Color = routeViewModel.Invoiced ? Color.FromArgb(255, 255, 127, 101) : Color.FromArgb(255, 67, 82, 102);
                routeLine.Width = 5;
                routeLine.Locations = new LocationCollection();
                var pushpin2 = new Pushpin
                {
                    Background = new SolidColorBrush(Colors.White)
                };
                MapLayer.SetPosition(pushpin2, routeViewModel.Locations.Last());

                routes[routeViewModel] = new Tuple<Pushpin, MapPolyline, Pushpin>(pushpin1, routeLine, pushpin2);


                MainMap.Children.Add(pushpin1);
                shapeLayer.Shapes.Add(routeLine);
                foreach (var routeLocation in routeViewModel.Locations)
                {
                    await Task.Delay(100);
                    routeLine.Locations.Add(routeLocation);
                }
                if (routes.ContainsKey(routeViewModel))
                {
                    MainMap.Children.Add(pushpin2);
                }
            }
            Debug.WriteLine("End");
        }
コード例 #20
0
ファイル: MainPage.xaml.cs プロジェクト: Navaneeth92/Xplore
        private async void OnMapTapped(object sender, TappedRoutedEventArgs e)
        {
            if (txtFromCoord.Text == "")
            {
                String loc = txtFromCoord.Text;
                var pos = e.GetPosition(NavMaps);
                Location location;
                NavMaps.TryPixelToLocation(pos, out location);

                MapLayer.SetPosition(Push, location);
                NavMaps.SetView(location);
                txtFromCoord.Text = Convert.ToString(location.Latitude) + "," + location.Longitude;
              
          



            }
            else
            {
            
                var pos = e.GetPosition(NavMaps);
                Location location;
                NavMaps.TryPixelToLocation(pos, out location);

                MapLayer.SetPosition(Push2, location);
                NavMaps.SetView(location);
                txtToCoord.Text = Convert.ToString(location.Latitude) + "," + location.Longitude;
                URL = "http://dev.virtualearth.net/REST/V1/Routes/Driving?o=json&wp.0=" + txtFromCoord.Text + "&wp.1=" + txtToCoord.Text + "&optmz=distance&rpo=Points&key=" + NavMaps.Credentials;
                Uri geocodeRequest = new Uri(URL);
                BingMapsRESTService.Response r = await GetResponse(geocodeRequest);

                geolocator = new Geolocator();
                MyPushPin = new Pushpin();

                FromLatitude = ((BingMapsRESTService.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[0][0];
                FromLongitude = ((BingMapsRESTService.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[0][1];

                location = new Location(FromLatitude, FromLongitude);
                MapLayer.SetPosition(MyPushPin, location);
                NavMaps.Children.Add(MyPushPin);
                NavMaps.SetView(location, 15.0f);

                MapPolyline routeLine = new MapPolyline();
                routeLine.Locations = new LocationCollection();
                routeLine.Color = Windows.UI.Colors.Blue;
                routeLine.Width = 5.0;
                // Retrieve the route points that define the shape of the route.
                int bound = ((BingMapsRESTService.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates.GetUpperBound(0);
                for (int i = 0; i < bound; i++)
                {
                    routeLine.Locations.Add(new Location
                    {
                        Latitude = ((BingMapsRESTService.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[i][0],
                        Longitude = ((BingMapsRESTService.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[i][1]
                    });
                }
                MapShapeLayer shapeLayer = new MapShapeLayer();
                shapeLayer.Shapes.Add(routeLine);
                NavMaps.ShapeLayers.Add(shapeLayer);
                txtFromCoord.Text = "";
                txtToCoord.Text = "";
            }
       
        }
コード例 #21
0
ファイル: MapControl.cs プロジェクト: Tmutsaers/HierInBreda
        async void MapView_userPosChanged(object sender, Bing.Maps.Location l)
        {
            UpdateUserRadius("0.1", l);
            userLoc = l;
            MapShapeLayer layer = new MapShapeLayer();
            if (pathLocations != null)
            {
                foreach (Bing.Maps.Location loc in pathLocations)
                {
                    if (inRadius(loc, l, 0.05))
                    {
                        insideRoute = true;
                        showWarn = false;
                        break;
                    }
                    else
                        if (!inRadius(loc, l, 0.05))
                        {

                            insideRoute = false;
                        }

                }
            }
            if(insideRoute == false && showWarn == false)
            {
                ResourceLoader rl = new ResourceLoader();
                mapView.popup = new Windows.UI.Popups.MessageDialog(rl.GetString("OffRoutePopup"), "Route");
                mapView.popup.Commands.Add(new UICommand(rl.GetString("Ok"), new UICommandInvokedHandler(this.CommandInvokedHandler)));
                showWarn = true;
                await mapView.popup.ShowAsync();
            }           
            
            //if (Route != null)
            //{
            //    if (userRadius.Intersects(Route.Bounds) && Route != null)
            //    {
            //        insideRoute = true;
            //    }
            //    else
            //        if (!userRadius.Intersects(Route.Bounds))
            //        {
            //            ResourceLoader rl = new ResourceLoader();
            //            mapView.popup = new Windows.UI.Popups.MessageDialog(rl.GetString("OffRoutePopup"), "Route");

            //            await mapView.popup.ShowAsync();
            //            insideRoute = false;
            //        }
            //}
        }
コード例 #22
0
ファイル: MainPage.xaml.cs プロジェクト: rvnijnatten/WeBreda
        private void updateVisitedLine()
        {
            Map.ShapeLayers.Remove(shapeLayerVisited);
            shapeLayerVisited = new MapShapeLayer();
            MapPolyline polyLine = new MapPolyline();
            polyLine.Color = Windows.UI.Colors.Green;
            polyLine.Width = 5;

            foreach(WeBreda.Model.Waypoint wp in this.control.currentRoute.Waypoints)
            {
                if(wp.IsVisited)
                {
                    polyLine.Locations.Add(new Location() { Latitude = wp.Latitude, Longitude = wp.Longitude });
                }
            }
            shapeLayerVisited.Shapes.Add(polyLine);
            Map.ShapeLayers.Add(shapeLayerVisited);

        }
コード例 #23
0
        private void ChooseButton_Click(object sender, RoutedEventArgs e)
        {
            //inCreatePolygonMode = true;

            // Clears any objects added to the polygon layer.
            //if (TockeShapeLayer.Shapes.Count > 0)
            //    TockeShapeLayer.Shapes.Clear();

            MapShapeLayer shapeLayer = new MapShapeLayer();
            

            newPolygon = new MapPolygon();
            // Defines the polygon fill details
            //newPolygon.Locations = new LocationCollection() { new Bing.Maps.Location(44, -107), new Location(44, -110), new Location(46, -110), new Location(46, -107) };
            newPolygon.FillColor = Windows.UI.Colors.Red;
            //newPolygon.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red);
            //newPolygon.StrokeThickness = 3;
            //newPolygon.Opacity = 0.8;
            shapeLayer.Shapes.Add(newPolygon);
            MyMap.ShapeLayers.Add(shapeLayer);
        }
コード例 #24
0
ファイル: DrowPath.cs プロジェクト: Voropash/CheaTaxiWin10
        async private Task DrawPath()
        {
            loading.Visibility = Visibility.Visible;
            // form and send request
            string tmpSourseLoc = Convert.ToString(sourseLocation.Latitude).Substring(0, Convert.ToString(sourseLocation.Latitude).IndexOf(',')) + '.' + Convert.ToString(sourseLocation.Latitude).Substring(Convert.ToString(sourseLocation.Latitude).IndexOf(',') + 1, Convert.ToString(sourseLocation.Latitude).Length - Convert.ToString(sourseLocation.Latitude).IndexOf(',') - 1);
            tmpSourseLoc += "," + Convert.ToString(sourseLocation.Longitude).Substring(0, Convert.ToString(sourseLocation.Longitude).IndexOf(',')) + '.' + Convert.ToString(sourseLocation.Longitude).Substring(Convert.ToString(sourseLocation.Longitude).IndexOf(',') + 1, Convert.ToString(sourseLocation.Longitude).Length - Convert.ToString(sourseLocation.Longitude).IndexOf(',') - 1);
            string tmpAimLoc = Convert.ToString(AimLocation.Latitude).Substring(0, Convert.ToString(AimLocation.Latitude).IndexOf(',')) + '.' + Convert.ToString(AimLocation.Latitude).Substring(Convert.ToString(AimLocation.Latitude).IndexOf(',') + 1, Convert.ToString(AimLocation.Latitude).Length - Convert.ToString(AimLocation.Latitude).IndexOf(',') - 1);
            tmpAimLoc += "," + Convert.ToString(AimLocation.Longitude).Substring(0, Convert.ToString(AimLocation.Longitude).IndexOf(',')) + '.' + Convert.ToString(AimLocation.Longitude).Substring(Convert.ToString(AimLocation.Longitude).IndexOf(',') + 1, Convert.ToString(AimLocation.Longitude).Length - Convert.ToString(AimLocation.Longitude).IndexOf(',') - 1);
            var url = "http://dev.virtualearth.net/REST/V1/Routes/Driving?o=json&wp.0=" +
                        tmpSourseLoc +
                        "&wp.1=" +
                        tmpAimLoc +
                        "&optmz=distance&rpo=Points&key=" + "2YNtFFMLLBJhNArw7AGF~J1bD5V8AXTm26ao0o20rRw~AqSRI8WDH0Mx820MLWME4SM-ye-FewEHmO7vj5O4vSDrNdVWsnRXo3I-LUhllJrB";
             Uri geocodeRequest = new Uri(url);
            BingMapHelper.Response r = await GetResponse(geocodeRequest);

            if (r.StatusCode != 404)
            {
                // Delete lables from map
                myMap.Children.Clear();
                myMap.ShapeLayers.Clear();

                // Draw Path via server answer 
                geolocator = new Geolocator();
                MapPolyline routeLine = new MapPolyline();
                routeLine.Locations = new LocationCollection();
                routeLine.Color = Windows.UI.Colors.RoyalBlue;
                routeLine.Width = 6.0;

                int bound = ((BingMapHelper.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates.GetUpperBound(0);

                sourseLocation.Latitude = ((BingMapHelper.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[0][0];
                sourseLocation.Longitude = ((BingMapHelper.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[0][1];

                AimLocation.Latitude = ((BingMapHelper.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[bound][0];
                AimLocation.Longitude = ((BingMapHelper.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[bound][1];

                var sourceLocation = new Bing.Maps.Location(sourseLocation.Latitude, sourseLocation.Longitude);
                myMap.Children.Add(pin);
                myMap.Children.Add(pinAim);

                var destinationLocation = new Bing.Maps.Location(AimLocation.Latitude, AimLocation.Longitude);
                myMap.SetView(sourceLocation, myMap.ZoomLevel);
                for (int i = 0; i < bound; i++)
                {
                    routeLine.Locations.Add(new Location
                        {
                            Latitude = ((BingMapHelper.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[i][0],
                            Longitude = ((BingMapHelper.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[i][1]
                        });
                }
                MapShapeLayer shapeLayer = new MapShapeLayer();
                shapeLayer.Shapes.Add(routeLine);
                myMap.ShapeLayers.Add(shapeLayer);
            }
            else
            {
                MessageDialog dialog = new MessageDialog("Маршрут построить не удалось. Попробуйте снова. \r\nЕсли ошибка повторится вновь, просим уведомить нас о ней через форму обратной связи.", "Ошибка построения маршрута #007100");
                await dialog.ShowAsync();
            }
            loading.Visibility = Visibility.Collapsed;
        }
コード例 #25
0
ファイル: MainPage.xaml.cs プロジェクト: Navaneeth92/Xplore
        private async void btnGiveDirections_Click(object sender, RoutedEventArgs e)
        {

          tbError.Text = string.Empty;
            if (rdCoord.IsChecked == true)
                URL = "http://dev.virtualearth.net/REST/V1/Routes/Driving?o=json&wp.0=" + txtFromCoord.Text + "&wp.1=" + txtToCoord.Text + "&optmz=distance&rpo=Points&key=" + NavMaps.Credentials;
            else
                URL = "http://dev.virtualearth.net/REST/V1/Routes/Driving?o=json&wp.0=" + txtFromLocation.Text + "&wp.1=" + txtToLocation.Text + "&optmz=distance&rpo=Points&key=" + NavMaps.Credentials;
            Uri geocodeRequest = new Uri(URL);
            BingMapsRESTService.Response r = await GetResponse(geocodeRequest);

            geolocator = new Geolocator();
            MyPushPin = new Pushpin();

            FromLatitude = ((BingMapsRESTService.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[0][0];
            FromLongitude = ((BingMapsRESTService.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[0][1];

            location = new Location(FromLatitude, FromLongitude);
            MapLayer.SetPosition(MyPushPin, location);
            NavMaps.Children.Add(MyPushPin);
            NavMaps.SetView(location, 15.0f);

            MapPolyline routeLine = new MapPolyline();
            routeLine.Locations = new LocationCollection();
            routeLine.Color = Windows.UI.Colors.Blue;
            routeLine.Width = 5.0;
            // Retrieve the route points that define the shape of the route.
            int bound = ((BingMapsRESTService.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates.GetUpperBound(0);
            for (int i = 0; i < bound; i++)
            {
                routeLine.Locations.Add(new Location
                {
                    Latitude = ((BingMapsRESTService.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[i][0],
                    Longitude = ((BingMapsRESTService.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[i][1]
                });
            }
            MapShapeLayer shapeLayer = new MapShapeLayer();
            shapeLayer.Shapes.Add(routeLine);
            NavMaps.ShapeLayers.Add(shapeLayer);
        }