Exemplo n.º 1
0
 public void ClearLayer(MapLayer layer)
 {
     if (layer != null)
     {
         layer.Clear();
     }
 }
Exemplo n.º 2
0
        void MostrarLugares()
        {
            MiMapa.MapElements.Clear();
            _puntosLayer.Clear();
            _posicionActualLayer.Clear();
            ReferencesListBox.ItemsSource = App.MapViewModel.ReferencesList;

            foreach (var mapPolyline in App.MapViewModel.Lines.Where(x => x.Key.Checked).Select(x => x.Value).SelectMany(line => line))
            {
                MiMapa.MapElements.Add(mapPolyline);
            }
            foreach (var mapOverlay in App.MapViewModel.Pushpins.Where(x => x.Key.Checked).Select(x => x.Value).SelectMany(pushpin => pushpin))
            {
                if (mapOverlay.ContentTemplate == null)
                {
                    mapOverlay.ContentTemplate = Application.Current.Resources["Pushpin"] as DataTemplate;
                }
                mapOverlay.PositionOrigin = new Point(0, 1);
                _puntosLayer.Add(mapOverlay);
            }

            //Si uso localizacion, agrego mi ubicación
            ActualizarUbicacion(App.Configuration.IsLocationEnabled ? App.Configuration.Ubicacion : null);

            MiMapa.SetView(MiMapa.CreateBoundingRectangle());
        }
Exemplo n.º 3
0
        private void ActualizarUbicacion(GeoPosition <GeoCoordinate> location)
        {
            _posicionActualLayer.Clear();
            if (location == null || location.Location.IsUnknown)
            {
                return;
            }

            var posicionActual = new MapOverlay
            {
                GeoCoordinate   = location.Location,
                ContentTemplate = Application.Current.Resources["locationPushpinTemplate"] as DataTemplate,
            };

            _posicionActualLayer.Add(posicionActual);
        }
 private void CenterLocation(GeoCoordinate gc)
 {
     UserLayer.Clear();
     UserLayer.Add(new MapOverlay()
     {
         GeoCoordinate = gc, Content = new UserLocationMarker()
     });
     TrackMap.Center  = gc;
     TrackMap.Heading = gc.Course;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Removes all point-of-interest pins from the map
        /// </summary>
        public static void ClearPointOfInterestPins(this Map m)
        {
            // clear all the overlays from the point-of-interest layer
            MapLayer poiLayer = PoiLayer(m);

            if (poiLayer != null)
            {
                poiLayer.Clear();
            }
        }
Exemplo n.º 6
0
        async void UpdateShowUserLocation()
        {
            if (Element.IsShowingUser)
            {
                var myGeolocator = new Geolocator();

                if (myGeolocator.LocationStatus != PositionStatus.NotAvailable &&
                    myGeolocator.LocationStatus != PositionStatus.Disabled)
                {
                    var userPosition = await myGeolocator.GetGeopositionAsync();

                    if (userPosition?.Coordinate != null)
                    {
                        LoadUserPosition(userPosition.Coordinate, true);
                    }
                }
            }
            else if (_userLocationLayer.Count > 0)
            {
                _userLocationLayer.Clear();
            }
        }
        //TODO: Initialize Diamond Pushpin
        private void InitializeDiamond()
        {
            int i = StaticData.CurrentErrollments.CompletedPlace;

            DiamondControl newDiamondControl = new DiamondControl();

            newDiamondControl.Tag = places[i];

            StaticViewModel.MapViewModel.currentPlace = places[i];

            diamondOverlay.Content       = newDiamondControl;
            diamondOverlay.GeoCoordinate = new GeoCoordinate(places[i].Latitude, places[i].Longitude);

            PlacesMapLayer.Clear();

            PlacesMapLayer.Add(diamondOverlay);

            //Test place

            Place testPlace = new Place();

            testPlace.GeoLocation = new GeoCoordinate(10.833769, 106.681338);
            testPlace.Latitude    = 10.833769;
            testPlace.Longitude   = 106.681338;

            testPlace.Content = "Test place";

            DiamondControl testDiamondControl = new DiamondControl();

            testDiamondControl.Tag = testPlace;

            MapOverlay testOverlay = new MapOverlay();

            testOverlay.Content       = testDiamondControl;
            testOverlay.GeoCoordinate = testPlace.GeoLocation;

            PlacesMapLayer.Add(testOverlay);
        }
Exemplo n.º 8
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            treinenLayer.Clear();

            websocket.MessageReceived += Websocket_MessageReceived;
            websocket.Open();


            bool keepValues = (e.NavigationMode == System.Windows.Navigation.NavigationMode.Back);

            if (this.NavigationContext.QueryString.ContainsKey("id"))
            {
                string station = this.NavigationContext.QueryString["id"];

                ViewModel.LoadStation(station);
            }

            //Is geo available?
            try
            {
                Geolocator geolocator = new Geolocator();

                if (geolocator.LocationStatus == PositionStatus.Disabled ||
                    geolocator.LocationStatus == PositionStatus.NotAvailable)
                {
                    this.ApplicationBar.IsVisible = false;
                }
                else
                {
                    this.ApplicationBar.IsVisible = true;
                }
            }
            catch { }
        }
Exemplo n.º 9
0
        private void ChageUserPosition(double lat, double lng)
        {
            Dispatcher.BeginInvoke(() =>
            {
                var myGeoCoordinate = new GeoCoordinate(lat, lng);

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

                _myLocationLayer.Clear();
                _myLocationLayer.Add(myLocationOverlay);

                this.MainMap.SetView(myGeoCoordinate, 15);
            });
        }
Exemplo n.º 10
0
        private void Gps_PositionChanged(object sender, GeoPositionChangedEventArgs <GeoCoordinate> e)
        {
            mapa.Center = e.Position.Location;

            Pushpin pin = new Pushpin();

            pin.Content = "VOCÊ";

            MapOverlay mapOv = new MapOverlay();

            mapOv.Content       = pin;
            mapOv.GeoCoordinate = e.Position.Location;

            MapLayer layer = new MapLayer();

            layer.Add(mapOv);
            layer.Clear();
        }
Exemplo n.º 11
0
        public PuntosSUBE()
        {
            InitializeComponent();

            Loaded += (s, e) =>
            {
                Panorama.Title      = ViewModel.Titulo;
                PanoramaItem.Header = ViewModel.Tipo;
                Mapa.Layers.Add(_pointsLayer);
                _pointsLayer.Clear();
                ViewModel.Puntos.Clear();

                DataContext = ViewModel;

                GetDondeComprar();
            };
            Unloaded += DondeCargar_Unloaded;
        }
Exemplo n.º 12
0
        void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (Pin pin in e.NewItems)
                {
                    LoadPin(pin);
                }
                break;

            case NotifyCollectionChangedAction.Move:
                // no matter
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (Pin pin in e.OldItems)
                {
                    RemovePin(pin);
                }
                break;

            case NotifyCollectionChangedAction.Replace:
                foreach (Pin pin in e.OldItems)
                {
                    RemovePin(pin);
                }
                foreach (Pin pin in e.NewItems)
                {
                    LoadPin(pin);
                }
                break;

            case NotifyCollectionChangedAction.Reset:
                _pushPinLayer.Clear();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 13
0
        void MostrarLugares()
        {
            //Limpio el mapa, tomo lugares de la tabla local y los agrego al mapa
            _puntosLayer.Clear();

            ReferencesListBox.ItemsSource = new List <MapReference>
            {
                new MapReference {
                    Id = 1, Nombre = "Ciclovias", Checked = true
                },
                new MapReference {
                    Id = 2, Nombre = "Estaciones", Checked = false
                },
                //new MapReference { Id = 3, Nombre = "Estacionamientos", Checked = false},
            };

            RenderBikeRoads();

            var query = from miLugar in BicicletaEstacionDC.Current.Estaciones
                        orderby miLugar.Id
                        select miLugar;

            Estaciones = new ObservableCollection <BicicletaEstacionTable>(query.ToList());

            foreach (var ml in Estaciones)
            {
                Pushpin nuevoLugar = new Pushpin
                {
                    Content       = ml.Nombre,
                    GeoCoordinate = new GeoCoordinate(ml.Latitud, ml.Longitud),
                    Visibility    = Visibility.Collapsed,
                };
                nuevoLugar.MouseLeftButtonUp += NuevoLugar_MouseLeftPuttonUp;
                MapExtensions.GetChildren(MiMapa).Add(nuevoLugar);
            }
            MiMapa.SetView(MiMapa.CreateBoundingRectangle());

            //Si uso localizacion, agrego mi ubicación
            ActualizarUbicacion(App.Configuration.IsLocationEnabled ? App.Configuration.Ubicacion : null);
        }
Exemplo n.º 14
0
        public StopDetailsView()
        {
            InitializeComponent();
            pushPinLayer = new MapLayer();
            this.MainMap.Layers.Add(pushPinLayer);

            Messenger.Default.Register <GenericMessage <GeoCoordinate> >(this, (msg) =>
            {
                if (msg.Sender == this.DataContext)
                {
                    pushPinLayer.Clear();

                    this.MainMap.Center    = msg.Content;
                    this.MainMap.ZoomLevel = 15;

                    Pushpin stop       = new Pushpin();
                    stop.GeoCoordinate = msg.Content;

                    var itemsColl = MapExtensions.GetChildren(MainMap).OfType <MapItemsControl>().First();
                    itemsColl.Items.Clear();
                    itemsColl.Items.Add(stop);
                }
            });
        }
Exemplo n.º 15
0
        private void UpdateLugar()
        {
            PageTitle.Text = _bicicletaEstacion.Nombre;
            Horario.Text   = _bicicletaEstacion.Horario;
            Estado.Text    = _bicicletaEstacion.Estado;
            Cantidad.Text  = _bicicletaEstacion.Cantidad.ToString(CultureInfo.InvariantCulture);
            Distancia.Text = string.IsNullOrWhiteSpace(_bicicletaEstacion.Distance) ? string.Empty : "distancia: " + _bicicletaEstacion.Distance;

            var nuevoLugar = new MapOverlay
            {
                Content         = _bicicletaEstacion.Nombre,
                GeoCoordinate   = new GeoCoordinate(_bicicletaEstacion.Latitud, _bicicletaEstacion.Longitud),
                ContentTemplate = Application.Current.Resources["Pushpin"] as DataTemplate,
            };
            var defaultLayer = new MapLayer();

            defaultLayer.Clear();
            defaultLayer.Add(nuevoLugar);

            MiMapa.Layers.Add(defaultLayer);
            MiMapa.Center           = new GeoCoordinate(_bicicletaEstacion.Latitud, _bicicletaEstacion.Longitud);
            MiMapa.CartographicMode = MapCartographicMode.Road;
            MiMapa.ZoomLevel        = 17;
        }
Exemplo n.º 16
0
        private void ExecCommand(string[] command)
        {
            MapLayer map = MapBox.CurrentMapLayer;

            command[0] = command[0].Trim().ToLower();

            if (command[0] == "set")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);

                map.SetObject(x, y, CurrentObject);
            }
            else if (command[0] == "fill")
            {
                map.FillObject(CurrentObject);
            }
            else if (command[0] == "clear")
            {
                map.Clear();
            }
            else if (command[0] == "rect")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);
                int w = int.Parse(command[3]);
                int h = int.Parse(command[4]);

                for (int py = y; py < y + h; py++)
                {
                    for (int px = x; px < x + w; px++)
                    {
                        map.SetObject(px, py, CurrentObject);
                    }
                }
            }
            else if (command[0] == "hline")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);
                int w = int.Parse(command[3]);

                for (int px = x; px < x + w; px++)
                {
                    map.SetObject(px, y, CurrentObject);
                }
            }
            else if (command[0] == "vline")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);
                int h = int.Parse(command[3]);

                for (int py = y; py < y + h; py++)
                {
                    map.SetObject(x, py, CurrentObject);
                }
            }
            else if (command[0] == "box")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);
                int w = int.Parse(command[3]);
                int h = int.Parse(command[4]);

                for (int px = x; px < x + w + 1; px++)
                {
                    map.SetObject(px, y, CurrentObject);
                    map.SetObject(px, y + h, CurrentObject);
                }
                for (int py = y; py < y + h; py++)
                {
                    map.SetObject(x, py, CurrentObject);
                    map.SetObject(x + w, py, CurrentObject);
                }
            }
            else if (command[0].StartsWith("print"))
            {
                int x  = int.Parse(command[1]);
                int y  = int.Parse(command[2]);
                int px = x;
                int py = y;

                string text = command[3];

                if (command.Length > 4)
                {
                    for (int i = 4; i < command.Length; i++)
                    {
                        text += " " + command[i];
                    }
                }

                foreach (char ch in text)
                {
                    GameObject o = new GameObject(CurrentObject);
                    o.Bytes.Clear();
                    o.Graphics.Index = ch;

                    if (ch == '\\')
                    {
                        px = x;
                        py++;
                    }
                    else
                    {
                        map.SetObject(px++, py, o);
                    }
                }
            }
            else if (command[0] == "select")
            {
                MapBox.SelectArea(
                    int.Parse(command[1]), int.Parse(command[2]),
                    int.Parse(command[3]), int.Parse(command[4]));

                MapBox.InvalidateAllMapPositionsAndRefresh();
                Log("Area selected: " + MapBox.GetSelectedArea());
            }
            else if (command[0] == "deselect")
            {
                MapBox.DeselectArea();
                MapBox.InvalidateAllMapPositionsAndRefresh();
                Log("Area deselected");
            }
            else if (command[0] == "erase")
            {
                MapBox.EraseSelectedArea();
                MapBox.InvalidateAllMapPositionsAndRefresh();
                Log("Selected area erased");
            }
            else if (command[0] == "copy")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);

                MapBox.CopySelectedAreaTo(x, y, false);
                MapBox.InvalidateAllMapPositionsAndRefresh();
                Log("Selected area copied to X:" + x + ",Y:" + y);
            }
            else if (command[0] == "cut")
            {
                int x = int.Parse(command[1]);
                int y = int.Parse(command[2]);

                MapBox.CopySelectedAreaTo(x, y, true);
                MapBox.InvalidateAllMapPositionsAndRefresh();
                Log("Selected area cut and pasted to X:" + x + ",Y:" + y);
            }
            else if (command[0] == "savesel")
            {
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.InitialDirectory = DataDirectory;
                dialog.Filter           = "PNG image files|*.png";
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                MapBox.SaveSelectedAreaAsImage(dialog.FileName);
                Log("Selected area saved to file:" + dialog.FileName);
            }

            MapBox.InvalidateAllMapPositionsAndRefresh();
        }
Exemplo n.º 17
0
        private void CreaterouteOverlays()
        {

            routedetails_layer = new MapLayer();
            routedetails_layer.Clear();
            MapOverlay overlay;
            if (routeNavDetails.Count > 1)
            {
                var imgwidth = 0;
                var imgheight = 0;
                double x = 0;
                double y = 0;
                for (int i = 0; i < routeNavDetails.Count; i++)
                {
                    var image1 = new Image();
                    if (i == 0)
                    {
                        image1.Source = new BitmapImage(new Uri("/Assets/start.png", UriKind.Relative));
                        imgwidth = 30;
                        imgheight = 30;
                        x = 0.0;
                        y = 0.9;
                    }
                    else if (i == routeNavDetails.Count - 1)
                    {
                        image1.Source = new BitmapImage(new Uri("/Assets/finish.png", UriKind.Relative));
                        imgwidth = 30;
                        imgheight = 30;
                        x = 1;
                        y = 0.9;
                    }
                    else
                    {
                        image1.Source = new BitmapImage(new Uri("/Assets/details.png", UriKind.Relative));
                        imgwidth = 20;
                        imgheight = 20;
                        x = 0.5;
                        y = 0.5;
                    }
                    image1.Width = imgwidth;
                    image1.Height = imgheight;
                    var poi = new RouteDetailsPois
                    {
                        instractions = routeNavDetails[i].instractions,
                        distance = routeNavDetails[i].distance / 1000.0,
                        coordinate =
                            new GeoCoordinate(routeNavDetails[i].coordinate.Latitude,
                                routeNavDetails[i].coordinate.Longitude)
                    };
                    image1.DataContext = poi;
                    image1.Tap += image1_Tap;
                    overlay = new MapOverlay
                    {
                        Content = image1,
                        GeoCoordinate =
                            new GeoCoordinate(routeNavDetails[i].coordinate.Latitude,
                                routeNavDetails[i].coordinate.Longitude),
                        PositionOrigin = new Point(x, y)
                    };
                    routedetails_layer.Add(overlay);
                }
                Mymap.Layers.Add(routedetails_layer);
            }
        }
Exemplo n.º 18
0
        /*
         * функция дляотрисовки маркеров поиска на карте.
         * Если задан параметр index, то необходимо отобразить только один маркер с указанным индексом.
         */
        private void DrawSearchMarkers(MapLayer mapLayer, int index = -1)
        {
            if (searchMapMarkers != null)
            {
                mapLayer.Clear();

                if (index != -1)
                {
                    DrawMapMarker(searchMapMarkers[index].Coordinate, searchMapMarkers[index].Kind, mapLayer, index);
                    RouteGuideMap.SetView(searchMapMarkers[index].Coordinate, RouteGuideMap.ZoomLevel, MapAnimationKind.Parabolic);
                }
                else
                {

                    for (int i = 0; i < searchMapMarkers.Count; i++)
                    {
                        DrawMapMarker(searchMapMarkers[i].Coordinate, searchMapMarkers[i].Kind, mapLayer, i);
                    }
                    RouteGuideMap.SetView(searchMapMarkers[0].Coordinate, RouteGuideMap.ZoomLevel, MapAnimationKind.Parabolic);
                }
            }
        }
Exemplo n.º 19
0
        /*
         * функция отрисовки маркера текущей позиции пользователя на соответствующем слое карты + 
         * отрисовка окружности погрешности определения текущей позиции пользователя
         */
        private void DrawMyPositionMarker(MapLayer mapLayer)
        {
            if (myMapMarker != null)
            {
                mapLayer.Clear();

                DrawMyLocationAccuracyRadius(mapLayer);
                DrawMapMarker(myMapMarker.Coordinate, myMapMarker.Kind, mapLayer);
            }
        }
Exemplo n.º 20
0
 public void ClearMap()
 {
     m_Terrain.Clear();
     m_Element.Clear();
 }