Esempio n. 1
0
        //<Maps:MapItemsControl x:Name="Meters" ItemsSource="{Binding Meters}">
        //            <Maps:MapItemsControl.ItemTemplate>
        //                <DataTemplate>
        //                    <StackPanel Maps:MapControl.NormalizedAnchorPoint="{Binding AnchorPoint}">
        //                        <Button x:Name="MapItemButton" Background="Transparent" Padding="0,-3,-3,0" Content="{Binding MeterInfo.MeterID}" Command="{Binding DataContext.UpdateSelectedMeterCommand, ElementName=Map, Mode=OneWay}" CommandParameter="{Binding MeterInfo.MeterID}">
        //                        </Button>

        //                        <Image Maps:MapControl.Location="{Binding Location}">
        //                            <Image.Source>
        //                                <BitmapImage UriSource = "{Binding ReadUpdated}" />
        //                            </ Image.Source >
        //                        </ Image >
        //                    </ StackPanel >
        //                </ DataTemplate >
        //            </ Maps:MapItemsControl.ItemTemplate>
        //        </Maps:MapItemsControl>
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            MeterModelCollection Meters = (MeterModelCollection)value;
            Uri             imgUri      = new Uri("ms-appx:///Assets/pushpin_Red.png");
            MapItemsControl MapControls = new MapItemsControl();

            foreach (MeterModel Meter in Meters)
            {
                if (Meter.ReadUpdated)
                {
                    imgUri = new Uri("ms-appx:///Assets/pushpin_Green.png");
                }

                MapIcon icon = new MapIcon()
                {
                    Image = RandomAccessStreamReference.CreateFromUri(imgUri),
                    NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0),
                    Location = new Geopoint(new BasicGeoposition()
                    {
                        Latitude = Meter.MeterInfo.Latitude, Longitude = Meter.MeterInfo.Longitude
                    }),
                    Title = Meter.MeterInfo.MeterId
                };

                MapControls.Items.Add(icon);
            }
            return(MapControls.Items);
        }
Esempio n. 2
0
        private void AddOrUpdateChild(MapItemsControl newControl)
        {
            bool done = false;

            foreach (var itemChild in this.Map.Children)
            {
                var control = itemChild as MapItemsControl;
                if (control.ItemsSource != null)
                {
                    if (control.ItemsSource.GetType() == newControl.ItemsSource.GetType())
                    {
                        if (newControl.ItemsSource.GetType() == typeof(List <Friend.All>))
                        {
                            control.ItemsSource = null;
                            control.ItemsSource = this.Friends;
                            done = true;
                        }
                    }
                }
            }

            if (done == false)
            {
                this.Map.Children.Add(newControl);
            }
        }
 public PushpinManager(MapControl nativeMap, CustomMap formsMap)
     : base(formsMap)
 {
     _nativeMap = nativeMap;
     _mapItems  = new MapItemsControl();
     _nativeMap.Children.Add(_mapItems);
     _pushpinMappings = new Dictionary <MapIcon, int>();
 }
        private void BindMapItemsControlItemsSource(string name, System.Collections.IEnumerable source)
        {
            // Finds the right control.
            MapItemsControl mapItemsControl = MapExtensions.GetChildren(MapControl)
                                              .OfType <MapItemsControl>()
                                              .First(mic => mic.Name == name);

            // Binds the property.
            mapItemsControl.ItemsSource = source;
        }
Esempio n. 5
0
        /// <summary>
        /// Cluster pins on the map
        /// </summary>
        public PushpinClusterer(Map map, MapItemsControl mapItemsControl, IEnumerable <IGeoCluster> pins, int distanceTreshold)
        {
            _map             = map;
            _mapItemsControl = mapItemsControl;

            _map.Children.Add(_mapItemsControl);
            _map.ViewChangeEnded += (s, e) => RenderPins();

            _pins             = pins.ToList();
            _distanceTreshold = distanceTreshold == 0 ? DefaultDistanceTreshold : distanceTreshold;
        }
Esempio n. 6
0
        public MapControlService(MapControl mapControl, MapItemsControl mapItems, MapItemsControl selectedItems)
        {
            _mapControl    = mapControl;
            _mapItems      = mapItems;
            _selectedItems = selectedItems;
            _mapControl.MapServiceToken = Configuration.MapKey;
            MapService.ServiceToken     = Configuration.MapKey;
            _geolocator = new MockGeolocator();

            var tickets = DataRepository.LoadTicketData();

            foreach (var ticket in tickets)
            {
                _ticketIcons.Add(new TicketIcon(ticket));
            }
        }
Esempio n. 7
0
        private void ToForgeChildren()
        {
            if (children == null)
            {
                children = MapExtensions.GetChildren(myMap);

                marker          = children.FirstOrDefault(x => x.GetType() == typeof(UserLocationMarker)) as UserLocationMarker;
                mapItemsControl = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl;
            }

            marker.GeoCoordinate = position.Coordinate.ToGeoCoordinate();

            if (pushpins.Count != 0)
            {
                mapItemsControl.ItemsSource = pushpins;
            }
        }
Esempio n. 8
0
        private static void OnItemsReceived(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var map = d as Map;

            if (map == null)
            {
                return;
            }

            var mapItems = new MapItemsControl();

            mapItems.ItemTemplate = d.GetValue(ClusterItemTemplateProperty) as DataTemplate;

            var distanceProperty = (int)d.GetValue(ClusterDistanceProperty);

            var items   = e.NewValue as IEnumerable <IGeoCluster>;
            var cluster = new PushpinClusterer(map, mapItems, items, distanceProperty);
        }
    private static void OnFixUpdateChanged(DependencyObject target, DependencyPropertyChangedEventArgs e)
    {
        MapItemsControl          mapItemsControl          = target as MapItemsControl;
        ItemsChangedEventHandler itemsChangedEventHandler = null;

        itemsChangedEventHandler = (object sender, ItemsChangedEventArgs ea) =>
        {
            if (ea.Action == NotifyCollectionChangedAction.Add)
            {
                EventHandler statusChanged = null;
                statusChanged = new EventHandler(delegate
                {
                    if (mapItemsControl.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
                    {
                        mapItemsControl.ItemContainerGenerator.StatusChanged -= statusChanged;
                        int index = ea.Position.Index + ea.Position.Offset;
                        ContentPresenter contentPresenter =
                            mapItemsControl.ItemContainerGenerator.ContainerFromIndex(index) as ContentPresenter;
                        if (VisualTreeHelper.GetChildrenCount(contentPresenter) == 1)
                        {
                            MapLayer mapLayer = GetVisualParent <MapLayer>(mapItemsControl);
                            mapLayer.ForceMeasure();
                        }
                        else
                        {
                            EventHandler layoutUpdated = null;
                            layoutUpdated = new EventHandler(delegate
                            {
                                if (VisualTreeHelper.GetChildrenCount(contentPresenter) == 1)
                                {
                                    contentPresenter.LayoutUpdated -= layoutUpdated;
                                    MapLayer mapLayer = GetVisualParent <MapLayer>(mapItemsControl);
                                    mapLayer.ForceMeasure();
                                }
                            });
                            contentPresenter.LayoutUpdated += layoutUpdated;
                        }
                    }
                });
                mapItemsControl.ItemContainerGenerator.StatusChanged += statusChanged;
            }
        };
        mapItemsControl.ItemContainerGenerator.ItemsChanged += itemsChangedEventHandler;
    }
Esempio n. 10
0
        public void Initialize(MapControl mapControl, Action <Type, object> navigateFunction)
        {
            _navigateFunction = navigateFunction;
            var deviceResponderUnit = DataRepository.GetUser();
            var mapItems            = new MapItemsControl();
            var selectedMapItems    = new MapItemsControl();

            mapControl.Children.Add(mapItems);
            mapControl.Children.Add(selectedMapItems);
            _mapService = new MapControlService(mapControl, mapItems, selectedMapItems);
            _mapService.CreateResponderForPriorityIncidentHandler += _responderManager.CreateResponderForPriorityIncident;
            _mapService.IncidentDatailsHandler += OnIncidentDetailsNavigated;
            LoadResponders();
            _mapService.LoadResponder(deviceResponderUnit);
            LoadIncidents();
            LoadUserRoles();
            IncidentToggleButtonChecked = true;
            OnIncidentToggleButtonClick();
        }
Esempio n. 11
0
        private void BindingMaps(IEnumerable <Venue> venues)
        {
            MapItemsControl.Clear();
            foreach (var venue in venues)
            {
                var layer  = new MapLayer();
                var canvas = new Button()
                {
                    BorderThickness = new Thickness(0, 0, 0, 0),
                    Width           = 65,
                    Height          = 97,
                    Background      =
                        new ImageBrush()
                    {
                        ImageSource =
                            new BitmapImage(new Uri(
                                                "/Assets/Icons/map.layer.png",
                                                UriKind.Relative))
                    },
                    Command = new RelayCommand(() =>
                    {
                        Messenger.Default.Send(venue, "ChangeLocation");
                        Messenger.Default.Send(new Uri("/GoBack.xaml", UriKind.Relative), "NavigationRequest");
                    })
                };

                layer.Add(new MapOverlay()
                {
                    Content       = canvas,
                    GeoCoordinate = new GeoCoordinate(venue.Lat, venue.Lng)
                });

                MapItemsControl.Add(layer);
            }
            Messenger.Default.Send <bool>(true, "MapUpdate");

            IsSync = false;
        }
Esempio n. 12
0
        private void PopulateMap(ItemViewModel pl)
        {
            pl.LastUpdate = "Updated: " + pl.UpdatedAt.ToString("f");
            pl.Icon       = GetSource(pl);
            pl.Coordinate = new GeoCoordinate(pl.Latitude, pl.Longitude);

            List <ItemViewModel> places = new List <ItemViewModel>();

            places.Add(pl);
            ObservableCollection <DependencyObject> children = MapExtensions.GetChildren(myMap);
            MapItemsControl obj = new MapItemsControl();

            obj.Items.Clear();
            obj.ItemsSource = null;
            obj             = children.FirstOrDefault(x => x is MapItemsControl) as MapItemsControl;

            if (obj != null && obj.Items.Count == 0)
            {
                obj.ItemsSource = places;
                TbkTitle.Text   = pl.Title;
                TbkReport.Text  = pl.Report;
                TbkUpdated.Text = "Updated: " + pl.UpdatedAt.ToString("f");
            }
        }
    private void OnLoadingItemsCompleted(object sender, EventArgs eventArgs)
    {
        // Don't care about thats
        ObservableCollection <DependencyObject> children = Microsoft.Phone.Maps.Toolkit.MapExtensions.GetChildren(map);
        MapItemsControl itemsControl = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl;

        // Here !
        foreach (GeolocalizableModel item in (this.DataContext as MyViewModel).Items)
        {
            Pushpin pushpin = new Pushpin();
            switch (item.PushpinTemplate)
            {
            case Server.PushpinTemplate.First:
                pushpin.Template = this.Resources["firstPushpinTemplate"] as ControlTemplate;
                break;

            case Server.PushpinTemplate.Second:
                pushpin.Template = this.Resources["secondPushpinTemplate"] as ControlTemplate;
                break;

            case Server.PushpinTemplate.Third:
                pushpin.Template = this.Resources["thirdPushpinTemplate"] as ControlTemplate;
                break;

            default:
                if (PushpinTemplate != null)
                {
                    pushpin.Template = PushpinTemplate;
                }
                break;
            }
            pushpin.Content       = item.PushpinContent;
            pushpin.GeoCoordinate = item.Location;
            itemsControl.Items.Add(pushpin);
        }
    }
Esempio n. 14
0
        private async Task GetFriends()
        {
            this.Loading = true;
            RaisePropertyChanged("Loading");

            friends_all = await FriendsRepository.GetFriends();

            //Try catch errond om te zorgen dat hij niet crasht bij lege bobs.
            if (this.friends_all != null)
            {
                for (int i = 0; i < friends_all.Count(); i++)
                {
                    try
                    {
                        Friend.All item = friends_all[i];
                        if (item.Location == null)
                        {
                            break;
                        }

                        item.VisibleShow      = Visibility.Collapsed;
                        item.ShowCommand      = new RelayCommand <object>(e => ShowFriend(e));
                        item.RouteCommand     = new RelayCommand <object>(e => mapItem_Friend(e));
                        item.RouteCommandText = "Toon route";

                        BasicGeoposition tempbasic = new BasicGeoposition();
                        //Locaties omzetten en in de tijdelijke posities opslaan.
                        tempbasic.Latitude  = ((Location)item.Location).Latitude;
                        tempbasic.Longitude = ((Location)item.Location).Longitude;

                        //Omzetten van tijdelijk punt naar echte locatie (anders krijg je die niet in de mapIconFeestLocation.Location)
                        Geopoint temppoint = new Geopoint(tempbasic);

                        MapIcon mapIconFeestLocation = new MapIcon();
                        mapIconFeestLocation.Location = temppoint; //Opgehaalde locatie
                                                                   //mapIconFeestLocation.Title = feest.Name; //Naam van het feestje;
                        mapIconFeestLocation.Image = MainViewVM.Pins.UserPin;
                        mapIconFeestLocation.Title = item.User1.ToString();
                        this.Map.MapElements.Add(mapIconFeestLocation);//Marker op de map zetten.
                    }
                    catch (Exception ex)
                    {
                    }
                }

                try
                {
                    var          newControl = new MapItemsControl();
                    ZoekVrienden vindrit    = MainViewVM.MainFrame.Content as ZoekVrienden;

                    newControl.ItemsSource  = friends_all;
                    newControl.ItemTemplate = (DataTemplate)vindrit.Resources["FriendsMapTemplate"] as DataTemplate;



                    AddOrUpdateChild(newControl);
                }
                catch (Exception)
                {
                }



                this.Friends = friends_all.Take(10).ToList();
                this.Loading = false;
                RaiseAll();
            }
        }
        private void AddOrUpdateChild(MapItemsControl newControl)
        {
            bool done = false;
            foreach (var itemChild in this.Map.Children)
            {
                var control = itemChild as MapItemsControl;
                if (control.ItemsSource != null)
                {
                    if (control.ItemsSource.GetType() == newControl.ItemsSource.GetType())
                    {
                        if (newControl.ItemsSource.GetType() == typeof(List<Party>))
                        {
                            control.ItemsSource = null;
                            control.ItemsSource = this.Parties;
                            done = true;
                        }

                      

                    }

                }

            }

            if (done == false)
            {
                this.Map.Children.Add(newControl);
            }

        }
        private async Task GetParties()
        {

            parties_all = await PartyRepository.GetParties();

            if (parties_all != null)
            {
                for (int i = 0; i < parties_all.Count; i++)
                {
                    try
                    {
                        Party item = parties_all[i];
                        if (item.Location == null)
                        {
                            break;
                        }
                        item.VisibleShow = Visibility.Collapsed;
                        item.ShowCommand = new RelayCommand<object>(e => ShowParty(e));
                        item.RouteCommand = new RelayCommand<object>(e => mapItem_Party(e));
                        item.TakeCommand = new RelayCommand<object>(e => TakeParty(e));
                        item.RouteCommandText = "Toon route";
                        if (MainViewVM.USER.IsBob.Value)
                        {
                            item.VisibleTake = Visibility.Collapsed;
                        }
                        else
                        {
                            item.VisibleTake = Visibility.Visible;
                        }

                        BasicGeoposition tempbasic = new BasicGeoposition();
                        //Locaties omzetten en in de tijdelijke posities opslaan.
                        tempbasic.Latitude = ((Location)item.Location).Latitude;
                        tempbasic.Longitude = ((Location)item.Location).Longitude;

                        //Omzetten van tijdelijk punt naar echte locatie (anders krijg je die niet in de mapIconFeestLocation.Location)
                        Geopoint temppoint = new Geopoint(tempbasic);

                        MapIcon mapIconFeestLocation = new MapIcon();
                        mapIconFeestLocation.Location = temppoint; //Opgehaalde locatie
                                                                   //mapIconFeestLocation.Title = feest.Name; //Naam van het feestje;
                        mapIconFeestLocation.Image = MainViewVM.Pins.FeestPin;
                        mapIconFeestLocation.Title = item.Name;
                        this.Map.MapElements.Add(mapIconFeestLocation);//Marker op de map zetten.

                    }
                    catch (Exception ex)
                    {


                    }

                }


                try
                {
                    var newControl = new MapItemsControl();
                    FeestjesOverzicht view = MainViewVM.MainFrame.Content as FeestjesOverzicht;

                    newControl.ItemsSource = parties_all;
                    newControl.ItemTemplate = (DataTemplate)view.Resources["PartiesMapTemplate"] as DataTemplate;

                    AddOrUpdateChild(newControl);
                }
                catch (Exception)
                {

                  
                }

                this.Parties = parties_all.Take(10).ToList();
                RaiseAll();
            }





        }
Esempio n. 17
0
        private void updateAllPins()
        {
            if (this.customPins != null)
            {
                int nOdx   = 0;
                int nCount = 0;

                nCount = this.customPins.Count;
                for (nOdx = 0; nOdx < nCount; nOdx++)
                {
                    string sPinLabel = this.customPins[nOdx].Latitude.ToString("F2").Substring(0, 2);
                    MapControl.Location        aLoc     = new MapControl.Location(this.customPins[nOdx].Latitude, this.customPins[nOdx].Longitude);
                    System.Windows.Media.Brush pinBrush = System.Windows.Media.Brushes.Blue;
                    if (this.customPins[nOdx].BluePin)
                    {
                        pinBrush = System.Windows.Media.Brushes.Blue;
                    }
                    else
                    {
                        /** Orange Push Pin */
                        pinBrush = System.Windows.Media.Brushes.Orange;
                    }

                    ObservableCollection <Point> somePushpins = new ObservableCollection <Point>();

                    /**
                     * From Xaml Map Control github code (codeplex)
                     *  Pushpins = new ObservableCollection<Point>();
                     *  Pushpins.Add(
                     *      new Point
                     *      {
                     *          Name = "WHV - Eckwarderhörne",
                     *          Location = new Location(53.5495, 8.1877)
                     *      });
                     **/

                    Point aPushPin = new Point {
                        Name     = sPinLabel,
                        Location = new MapControl.Location(aLoc.Latitude, aLoc.Longitude)
                    };

                    System.Windows.Style style = new System.Windows.Style {
                        TargetType = typeof(MapItem)
                    };
                    style.Setters.Add(new System.Windows.Setter(MapPanel.LocationProperty, aLoc));
                    style.Setters.Add(new System.Windows.Setter(MapItem.VerticalContentAlignmentProperty, System.Windows.VerticalAlignment.Bottom));
                    style.Setters.Add(new System.Windows.Setter(MapItem.ForegroundProperty, System.Windows.Media.Brushes.Black));
                    style.Setters.Add(new System.Windows.Setter(MapItem.BackgroundProperty, pinBrush));
                    style.Setters.Add(new System.Windows.Setter(MapItem.VisibilityProperty, System.Windows.Visibility.Visible));
                    System.Windows.FrameworkElementFactory aPin = new FrameworkElementFactory(typeof(MapControl.Pushpin));
                    aPin.SetValue(MapControl.Pushpin.ContentProperty, sPinLabel);
                    aPin.SetValue(MapControl.Pushpin.ForegroundProperty, System.Windows.Media.Brushes.Black);
                    aPin.SetValue(MapControl.Pushpin.BackgroundProperty, pinBrush);
                    System.Windows.Controls.ControlTemplate ct = new System.Windows.Controls.ControlTemplate(typeof(MapControl.MapItem));
                    ct.VisualTree = aPin;
                    style.Setters.Add(new System.Windows.Setter(MapItem.TemplateProperty, ct));

                    somePushpins.Add(aPushPin);

                    MapControl.MapItemsControl aControl = new MapItemsControl {
                        ItemsSource                   = somePushpins,
                        ItemContainerStyle            = style,
                        IsSynchronizedWithCurrentItem = true
                    };

                    Control.Children.Add(aControl);
                }
            }
        }
Esempio n. 18
0
        private void Map_Loaded(object sender, RoutedEventArgs e)
        {
            MapControl map = (MapControl)sender;

            map.Center = (App.Current as App).GeoLocator.currentPosition.Coordinate.Point;

            map.ZoomLevel = 13;

            // Create a small circle to mark the current location.
            Ellipse myCircle = new Ellipse();
            myCircle.Fill = new SolidColorBrush(Colors.Blue);
            myCircle.Height = 20;
            myCircle.Width = 20;
            myCircle.Opacity = 50;

            MapItemsControl mEl = new MapItemsControl();
            MapIcon ii = new MapIcon();

            /*
            // Create a MapOverlay to contain the circle.
            Map myLocationOverlay = new MapOverlay();
            myLocationOverlay.Content = myCircle;
            myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate = myGeoCoordinate;*/


        }
        private async Task GetUsers()
        {
            this.Users = await UsersRepository.GetUsersOnline();

            //Try catch errond om te zorgen dat hij niet crasht bij lege bobs.
            if (this.Users != null)
            {
                for (int i = 0; i < this.Users.Count(); i++)
                {
                    try
                    {
                        User.All item = this.Users[i];
                        if (item.Location == null)
                        {
                            break;
                        }

                        item.VisibleShow = Visibility.Collapsed;
                        item.ShowCommand = new RelayCommand<object>(e => ShowUser(e));
                        item.RouteCommand = new RelayCommand<object>(e => mapItem_User(e));
                        item.RouteCommandText = "Toon route";

                        BasicGeoposition tempbasic = new BasicGeoposition();
                        //Locaties omzetten en in de tijdelijke posities opslaan.
                        tempbasic.Latitude = ((Location)item.Location).Latitude;
                        tempbasic.Longitude = ((Location)item.Location).Longitude;

                        //Omzetten van tijdelijk punt naar echte locatie (anders krijg je die niet in de mapIconFeestLocation.Location)
                        Geopoint temppoint = new Geopoint(tempbasic);

                        MapIcon mapIconFeestLocation = new MapIcon();
                        mapIconFeestLocation.Location = temppoint; //Opgehaalde locatie
                                                                   //mapIconFeestLocation.Title = feest.Name; //Naam van het feestje;
                        mapIconFeestLocation.Image = MainViewVM.Pins.UserPin;
                        mapIconFeestLocation.Title = item.User.ToString();
                        this.Map.MapElements.Add(mapIconFeestLocation);//Marker op de map zetten.
                    }
                    catch (Exception ex)
                    {


                    }

                }

                try
                {
                    var newControl = new MapItemsControl();
                    VindRit vindrit = MainViewVM.MainFrame.Content as VindRit;

                    newControl.ItemsSource = this.Users;
                    newControl.ItemTemplate = (DataTemplate)vindrit.Resources["UsersMapTemplate"] as DataTemplate;



                    AddOrUpdateChild(newControl);
                }
                catch (Exception)
                {

                   
                }




                RaiseAll();


            }


        }
        private async Task GetDestinations()
        {

            this.Destinations= await DestinationRepository.GetDestinations();
           
            if (this.Destinations != null && this.Destinations.Count != 0)
            {
                VindRitFilterVM.SelectedDestination = this.Destinations.Where(r => r.Default == true).First();
            }


            if (this.Destinations != null)
            {
                for (int i = 0; i < this.Destinations.Count(); i++)
                {
                    try
                    {
                        Users_Destinations item = this.Destinations[i];
                        if (item.Location == null)
                        {
                            break;
                        }
                        item.VisibleShow = Visibility.Collapsed;
                        item.ShowCommand = new RelayCommand<object>(e => ShowDestination(e));
                       

                        BasicGeoposition tempbasic = new BasicGeoposition();
                        //Locaties omzetten en in de tijdelijke posities opslaan.
                        tempbasic.Latitude = ((Location)item.Location).Latitude;
                        tempbasic.Longitude = ((Location)item.Location).Longitude;

                        //Omzetten van tijdelijk punt naar echte locatie (anders krijg je die niet in de mapIconFeestLocation.Location)
                        Geopoint temppoint = new Geopoint(tempbasic);

                        MapIcon mapIconFeestLocation = new MapIcon();
                        mapIconFeestLocation.Location = temppoint; //Opgehaalde locatie
                                                                   //mapIconFeestLocation.Title = feest.Name; //Naam van het feestje;
                        mapIconFeestLocation.Image = MainViewVM.Pins.HomePin;
                        mapIconFeestLocation.Title = item.Name;
                        this.Map.MapElements.Add(mapIconFeestLocation);//Marker op de map zetten.

                    }
                    catch (Exception ex)
                    {


                    }

                }


                try
                {
                    var newControl = new MapItemsControl();
                    VindRit vindrit = MainViewVM.MainFrame.Content as VindRit;

                    newControl.ItemsSource = Destinations;
                    newControl.ItemTemplate = (DataTemplate)vindrit.Resources["DestinationsMapTemplate"] as DataTemplate;

                    AddOrUpdateChild(newControl);
                }
                catch (Exception)
                {

                   
                }


                RaiseAll();
            }





        }
        private void updateAllPins()
        {
            if (this.customPins != null)
            {
                int nOdx   = 0;
                int nCount = 0;

                // this.nativeMap.Children.Clear();
                // this.nativeMap.MapElements.Clear();

                nCount = this.customPins.Count;
                for (nOdx = 0; nOdx < nCount; nOdx++)
                {
                    string sPinLabel = this.customPins[nOdx].Latitude.ToString("F2").Substring(0, 2);
                    MapControl.Location        aLoc     = new MapControl.Location(this.customPins[nOdx].Latitude, this.customPins[nOdx].Longitude);
                    System.Windows.Media.Brush pinBrush = System.Windows.Media.Brushes.Blue;
                    if (this.customPins[nOdx].BluePin)
                    {
                        pinBrush = System.Windows.Media.Brushes.Blue;
                    }
                    else
                    {
                        /** Orange Push Pin */
                        pinBrush = System.Windows.Media.Brushes.Orange;
                    }

                    ObservableCollection <Point> somePushpins = new ObservableCollection <Point>();
                    // ObservableCollection<MapControl.Pushpin> somePushpins = new ObservableCollection<MapControl.Pushpin>();

                    /**
                     * From Xaml Map Control github code (codeplex)
                     *  Pushpins = new ObservableCollection<Point>();
                     *  Pushpins.Add(
                     *      new Point
                     *      {
                     *          Name = "WHV - Eckwarderhörne",
                     *          Location = new Location(53.5495, 8.1877)
                     *      });
                     **/

                    Point aPushPin = new Point {
                        // MapControl.Pushpin aPushPin = new MapControl.Pushpin
                        Name     = sPinLabel,
                        Location = new MapControl.Location(aLoc.Latitude, aLoc.Longitude)
                                   //Content = sPinLabel,
                                   //// Location = new MapControl.Location(42.2917° N, 85.5872° W),
                                   //Location = aLoc,
                                   //Foreground = System.Windows.Media.Brushes.Black,
                                   //Visibility = Visibility.Visible
                    };

                    System.Windows.Style style = new System.Windows.Style {
                        TargetType = typeof(MapItem)
                    };
                    // style.Setters.Add(new EventSetter(MapItem.TouchDownEvent, new RoutedEventHandler( Map2ItemTouchDown )));
                    // style.Setters.Add(new System.Windows.Setter( MapItem.LocationProperty, aLoc));
                    style.Setters.Add(new System.Windows.Setter(MapPanel.LocationProperty, aLoc));
                    style.Setters.Add(new System.Windows.Setter(MapItem.VerticalContentAlignmentProperty, System.Windows.VerticalAlignment.Bottom));
                    style.Setters.Add(new System.Windows.Setter(MapItem.ForegroundProperty, System.Windows.Media.Brushes.Black));
                    style.Setters.Add(new System.Windows.Setter(MapItem.BackgroundProperty, pinBrush));
                    style.Setters.Add(new System.Windows.Setter(MapItem.VisibilityProperty, System.Windows.Visibility.Visible));
                    System.Windows.FrameworkElementFactory aPin = new FrameworkElementFactory(typeof(MapControl.Pushpin));
                    aPin.SetValue(MapControl.Pushpin.ContentProperty, sPinLabel);
                    aPin.SetValue(MapControl.Pushpin.ForegroundProperty, System.Windows.Media.Brushes.Black);
                    aPin.SetValue(MapControl.Pushpin.BackgroundProperty, pinBrush);
                    System.Windows.Controls.ControlTemplate ct = new System.Windows.Controls.ControlTemplate(typeof(MapControl.MapItem));
                    ct.VisualTree = aPin;
                    style.Setters.Add(new System.Windows.Setter(MapItem.TemplateProperty, ct));

                    somePushpins.Add(aPushPin);
                    //map.Children.Add(new MapItemsControl { ItemsSource=somePushpins, ItemContainerStyle = MainWindow.PushpinItemStyle });

                    MapControl.MapItemsControl aControl = new MapItemsControl {
                        ItemsSource                   = somePushpins,
                        ItemContainerStyle            = style,
                        IsSynchronizedWithCurrentItem = true
                    };

                    //MapControl.Pushpin aPushPinA = new Pushpin {
                    //    Content = "My Push Pin A",
                    //    Location = new MapControl.Location(21.821, 33.286),
                    //    Foreground = System.Windows.Media.Brushes.Blue,
                    //    Visibility = Visibility.Visible
                    //};

                    // map.Children.Add(aPushPinA);
                    Control.Children.Add(aControl);
                    //// MapControl.Location aLoc = new MapControl.Location(this.customPins[nOdx].Latitude, this.customPins[nOdx].Longitude);
                    //// if (this.customPins[nOdx].BluePin) {
                    ////System.Windows.Media.Color aColorBlue = System.Windows.Media.Color.FromRgb(0, 0, 255);
                    ////System.Windows.Media.Color aColorWhite = System.Windows.Media.Color.FromRgb(255, 255, 255);
                    ////MapControl.Pushpin aPin = new MapControl.Pushpin {
                    ////    Location = aLoc,
                    ////    Background = new System.Windows.Media.SolidColorBrush(aColorBlue),
                    ////    Foreground = new System.Windows.Media.SolidColorBrush(aColorWhite)
                    ////};
                    //Xamarin.Forms.Maps.Pin aNewPin = new Pin();
                    //aNewPin.Position = new Position(this.customPins[nOdx].Latitude, this.customPins[nOdx].Longitude);
                    //aNewPin.Label = "";
                    ////Control.Children.Add(aPin);
                    //Element.Pins.Add(aNewPin);
                    ////     } else {
                    ////         System.Windows.Media.Color aColorOrange = System.Windows.Media.Color.FromRgb(255, 128, 0);
                    ////         System.Windows.Media.Color aColorWhite = System.Windows.Media.Color.FromRgb(255, 255, 255);
                    ////         MapControl.Pushpin aPin = new MapControl.Pushpin {
                    ////             Location = aLoc,
                    ////             Background = new System.Windows.Media.SolidColorBrush(aColorOrange),
                    ////             Foreground = new System.Windows.Media.SolidColorBrush(aColorWhite)
                    ////         };
                    //////Control.Children.Add(aPin);
                    ////     }
                    //// Microsoft.Maps.MapControl.WPF.Location aLoc = new Microsoft.Maps.MapControl.WPF.Location(pin.Position.Latitude, pin.Position.Longitude); //Convert.ToDouble( _myGeocodeInfo[8]),Convert.ToDouble(_myGeocodeInfo[9]));
                    ////Microsoft.Maps.MapControl.WPF.Pushpin aPin = new Microsoft.Maps.MapControl.WPF.Pushpin();
                    ////Microsoft.Maps.MapControl.WPF.MapLayer.SetPosition(aPin, aLoc);
                    ////         Microsoft.Maps.MapControl.WPF.Location aLoc = new Microsoft.Maps.MapControl.WPF.Location(this.customPins[nOdx].Latitude, this.customPins[nOdx].Longitude);
                    ////         Microsoft.Maps.MapControl.WPF.Pushpin aPin = new Microsoft.Maps.MapControl.WPF.Pushpin();
                    ////         Microsoft.Maps.MapControl.WPF.MapLayer.SetPosition(aPin, aLoc);
                    ////Control.Children.Add(aPin);
                    ////var snPosition = new BasicGeoposition { Latitude = this.customPins[nOdx].Latitude, Longitude = this.customPins[nOdx].Longitude };
                    ////var snPoint = new Geopoint(snPosition);
                    ////var mapIcon = new MapIcon();

                    ////if (this.customPins[nOdx].BluePin) {
                    ////    string sUriString = "ms-appx:///bluemappin50.png";
                    ////    mapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri(sUriString));
                    ////} else {
                    ////    string sUriString = "ms-appx:///orangemappin50.png";
                    ////    mapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri(sUriString));
                    ////}
                    ////mapIcon.CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible;
                    ////mapIcon.Location = snPoint;
                    ////mapIcon.NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0);

                    ////this.nativeMap.MapElements.Add(mapIcon);
                }
            }
        }
 public GlobalPositioningSystemForMap(MapItemsControl mapControl, Map map)
 {
     this.mapControl = mapControl;
     this.map = map;
 }
Esempio n. 23
0
        private async Task GetParties()
        {
            parties_all = await PartyRepository.GetParties();

            if (parties_all != null)
            {
                for (int i = 0; i < parties_all.Count; i++)
                {
                    try
                    {
                        Party item = parties_all[i];
                        if (item.Location == null)
                        {
                            break;
                        }
                        item.VisibleShow      = Visibility.Collapsed;
                        item.ShowCommand      = new RelayCommand <object>(e => ShowParty(e));
                        item.RouteCommand     = new RelayCommand <object>(e => mapItem_Party(e));
                        item.TakeCommand      = new RelayCommand <object>(e => TakeParty(e));
                        item.RouteCommandText = "Toon route";
                        if (MainViewVM.USER.IsBob.Value)
                        {
                            item.VisibleTake = Visibility.Collapsed;
                        }
                        else
                        {
                            item.VisibleTake = Visibility.Visible;
                        }

                        BasicGeoposition tempbasic = new BasicGeoposition();
                        //Locaties omzetten en in de tijdelijke posities opslaan.
                        tempbasic.Latitude  = ((Location)item.Location).Latitude;
                        tempbasic.Longitude = ((Location)item.Location).Longitude;

                        //Omzetten van tijdelijk punt naar echte locatie (anders krijg je die niet in de mapIconFeestLocation.Location)
                        Geopoint temppoint = new Geopoint(tempbasic);

                        MapIcon mapIconFeestLocation = new MapIcon();
                        mapIconFeestLocation.Location = temppoint; //Opgehaalde locatie
                                                                   //mapIconFeestLocation.Title = feest.Name; //Naam van het feestje;
                        mapIconFeestLocation.Image = MainViewVM.Pins.FeestPin;
                        mapIconFeestLocation.Title = item.Name;
                        this.Map.MapElements.Add(mapIconFeestLocation);//Marker op de map zetten.
                    }
                    catch (Exception ex)
                    {
                    }
                }


                try
                {
                    var newControl         = new MapItemsControl();
                    FeestjesOverzicht view = MainViewVM.MainFrame.Content as FeestjesOverzicht;

                    newControl.ItemsSource  = parties_all;
                    newControl.ItemTemplate = (DataTemplate)view.Resources["PartiesMapTemplate"] as DataTemplate;

                    AddOrUpdateChild(newControl);
                }
                catch (Exception)
                {
                }

                this.Parties = parties_all.Take(10).ToList();
                RaiseAll();
            }
        }