Esempio n. 1
0
        public void addEventsToMap(List<PointOfInterest> list)
        {
            int i = 0;
            foreach (WeBreda.Model.PointOfInterest wp in list)
            {
                Bing.Maps.Directions.Waypoint bingwp = new Bing.Maps.Directions.Waypoint(new Location()
                {
                    Latitude = wp.Latitude,
                    Longitude = wp.Longitude
                });

                createGeofence(bingwp, EventId + i);

                Pushpin pin = new Pushpin();
                pin.Background = new SolidColorBrush(Colors.Red);
                pin.Tapped += new TappedEventHandler(pushpinTapped);
                pin.Tag = GeofenceId + EventId + i;
                MapLayer.SetPosition(pin, bingwp.Location);
                Map.Children.Add(pin);
                i++;
            }
        }
Esempio n. 2
0
        public async Task calculateRoute(List<WeBreda.Model.Waypoint> wpList)
        {
            routeCollection.Clear();
            directionsManager.Waypoints.Clear();
            WaypointCollection wpCollection = new WaypointCollection();

            foreach (WeBreda.Model.Waypoint wp in wpList)
            {
                Bing.Maps.Directions.Waypoint bingwp = new Bing.Maps.Directions.Waypoint(new Location()
                {
                    Latitude = wp.Latitude,
                    Longitude = wp.Longitude
                });

                Debug.Print(wp.Latitude + " " + wp.Longitude);

                directionsManager.Waypoints.Add(bingwp);
                wpCollection.Add(bingwp);
 
                if (directionsManager.Waypoints.Count > 4)
                {
                    Bing.Maps.Directions.RouteResponse response = await directionsManager.CalculateDirectionsAsync();
                    if (response.Routes.Count > 0)
                    {
                        Bing.Maps.Directions.Route route = response.Routes[0];
                        routeCollection.Add(route);
                        waypointCollectionList.Add(wpCollection);
                        wpCollection = new WaypointCollection();
                        directionsManager.Waypoints.Clear();
                        directionsManager.Waypoints.Add(bingwp);
                        wpCollection.Add(bingwp);
                    }
                }
            }

            drawRouteLine(wpList);
            routeIndex = control.currentRoute.RouteIndex;
            directionsManager.ActiveRoute = routeCollection[routeIndex];
            routeCalculated = true;
        }
Esempio n. 3
0
        public void addWaypointToMap(List<WeBreda.Model.Waypoint> wpList)
        {
            List<Geofence> geofences = GeofenceMonitor.Current.Geofences.Where(geo => geo.Id.StartsWith(GeofenceId)).ToList();
            foreach(Geofence geofence in geofences)
            {
                GeofenceMonitor.Current.Geofences.Remove(geofence);
            }
            List<UIElement> pushpins = Map.Children.Where((uElm => uElm is Pushpin)).ToList();
            foreach(UIElement uElm in pushpins)
            {
                Map.Children.Remove(uElm);
            }

            int i = 0;

            foreach (WeBreda.Model.Waypoint wp in wpList)
            {
                Bing.Maps.Directions.Waypoint bingwp = new Bing.Maps.Directions.Waypoint(new Location(){
                    Latitude = wp.Latitude,
                    Longitude = wp.Longitude
                });

                createGeofence(bingwp, i + "");

                if (wp is PointOfInterest)
                {
                    Pushpin pin = new Pushpin();
                    pin.Tapped += new TappedEventHandler(pushpinTapped);
                    pin.Tag = GeofenceId + i;
                    MapLayer.SetPosition(pin, bingwp.Location);
                    Map.Children.Add(pin);
                }
                i++;
            }
        }