Ejemplo n.º 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Map()
        {
            InitializeComponent();

            // Make sure that data context is loaded
            if (!App.ViewModel.IsDataLoaded)
            {
                App.ViewModel.LoadData();
            }

            // Set the data context
            DataContext = App.ViewModel;

            // Set up map view & map pushpin
#if WP8
            MapView                  = new Microsoft.Phone.Maps.Controls.Map();
            MapPushpin               = new Microsoft.Phone.Maps.Toolkit.Pushpin();
            MapPushpin.Name          = "MapPushpin";
            MapPushpin.GeoCoordinate = App.ViewModel.Restaurant.Location;

            ObservableCollection <DependencyObject> children = MapExtensions.GetChildren(MapView);
            children.Add(MapPushpin);
            MapExtensionsSetup(MapView);
#else
            MapView = new Microsoft.Phone.Controls.Maps.Map();
            MapView.ZoomBarVisibility = Visibility.Visible;
            MapPushpin          = new Microsoft.Phone.Controls.Maps.Pushpin();
            MapPushpin.Location = App.ViewModel.Restaurant.Location;
            MapView.Children.Add(MapPushpin);
#endif
            MapView.ZoomLevel = 12;
            MapView.Center    = App.ViewModel.Restaurant.Location;
            ContentPanel.Children.Add(MapView);
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            string quakeQueryString = string.Empty;

            if (NavigationContext.QueryString.TryGetValue("quake", out quakeQueryString))
            {
                quake = Earthquake.DeserializeFromQueryString(quakeQueryString);
            }
            else return;

            ContentPanel.DataContext = quake;

            QuakeMap.Center = quake.Location;
            Pushpin pin = new Pushpin
            {
                GeoCoordinate = quake.Location,
                Content = quake.FormattedMagnitude
            };
            if (quake.Magnitude >= appSettings.MinimumWarningMagnitudeSetting)
                pin.Background = Application.Current.Resources["PhoneAccentBrush"] as SolidColorBrush;

            MapOverlay overlay = new MapOverlay();
            overlay.Content = pin;
            overlay.GeoCoordinate = quake.Location;
            overlay.PositionOrigin = new Point(0, 1);

            MapLayer layer = new MapLayer();
            layer.Add(overlay);
            QuakeMap.Layers.Add(layer);

            base.OnNavigatedTo(e);
        }
Ejemplo n.º 3
0
        void GenerarMap()
        {
            //double lat = 13.3039361;
            //double longi = -87.1818977;

            //double myLat = 13.309102541101671;
            //double myLongi = -87.18679750841795;

            myCoordinates.Add(new System.Device.Location.GeoCoordinate(lat, longi));
            myCoordinates.Add(new System.Device.Location.GeoCoordinate(myLat, myLongi));

            

            //myGeocode = new GeocodeQuery();
            //myGeocode.GeoCoordinate = new System.Device.Location.GeoCoordinate(myLat, myLongi);
            //myGeocode.QueryCompleted += myGeocode_QueryCompleted;
            //myGeocode.QueryAsync();

            myQuery = new RouteQuery();
            myQuery.Waypoints = myCoordinates;
            myQuery.QueryCompleted += myQuery_QueryCompleted;
            myQuery.QueryAsync();
            mapPlace.Center = new System.Device.Location.GeoCoordinate(myLat, myLongi);

           
            MapLayer myLayer = new MapLayer();

            Pushpin myPushpin = new Pushpin();
            MapOverlay myOverlay = new MapOverlay();
            myPushpin.GeoCoordinate = new System.Device.Location.GeoCoordinate(myLat, myLongi);

            myPushpin.Content = "I'm Here";

            myOverlay.Content = myPushpin;
            myOverlay.GeoCoordinate = new System.Device.Location.GeoCoordinate(myLat, myLongi);
            myLayer.Add(myOverlay);

            Pushpin pushpin = new Pushpin();
            MapOverlay overlay = new MapOverlay();
            pushpin.GeoCoordinate = new System.Device.Location.GeoCoordinate(lat, longi);

            pushpin.Content = PlaceName;

            overlay.Content = pushpin;
            overlay.GeoCoordinate = new System.Device.Location.GeoCoordinate(lat, longi);
            myLayer.Add(overlay);

            mapPlace.Layers.Add(myLayer);

            //Animacion del mapa
            mapPlace.SetView(new System.Device.Location.GeoCoordinate()
            {
                Latitude = lat,
                Longitude = longi
            }, 16, Microsoft.Phone.Maps.Controls.MapAnimationKind.Parabolic);


            
        }
Ejemplo n.º 4
0
        public detail()
        {
            InitializeComponent();
            List<Stand> tab = (List<Stand>)PhoneApplicationService.Current.State["stands"];
            int index = (int)PhoneApplicationService.Current.State["index"];

            //MessageBox.Show(index.ToString());
            Stand item = tab[index];

            station_id.Text = "Station n°" + item.Id;
            add.Text = item.Add.ToString();
            ab.Text = "Places : " + item.Ab.ToString();
            ap.Text = "Velos : " + item.Ap.ToString();
            ac.Text = "Capacité disponible : " + item.Ac.ToString();
            tc.Text = "Capacité totale: : " + item.Tc.ToString();

            GeoCoordinate loc = new GeoCoordinate();
            //Location loc = new Location();
            loc.Longitude = item.Lng;
            loc.Latitude = item.Lat;

            Map Carte = new Map();
            Carte.Center = loc;
            Carte.ZoomLevel = 17.0;

            Pushpin pin = new Pushpin();
            pin.GeoCoordinate = loc;
            //pin.Location = loc;
            ContentMap.Children.Add(Carte);

            ImageBrush imgBrush = new ImageBrush();
            imgBrush.Stretch = System.Windows.Media.Stretch.UniformToFill;
            imgBrush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"velo_bleu.png", UriKind.Relative));

            Grid MyGrid = new Grid();
            MyGrid.RowDefinitions.Add(new RowDefinition());
            MyGrid.RowDefinitions.Add(new RowDefinition());
            MyGrid.Background = new SolidColorBrush(Colors.Transparent);

            Rectangle MyRectangle = new Rectangle();
            MyRectangle.Fill = imgBrush;
            MyRectangle.Height = 52;
            MyRectangle.Width = 85;
            MyRectangle.SetValue(Grid.RowProperty, 0);
            MyRectangle.SetValue(Grid.ColumnProperty, 0);

            MyGrid.Children.Add(MyRectangle);

            MapLayer layer = new MapLayer();
            MapOverlay overlay = new MapOverlay();
            overlay.GeoCoordinate = pin.GeoCoordinate;
            overlay.Content = MyGrid;
            layer.Add(overlay);

            //Carte.Children.Add(pin);
            Carte.Layers.Add(layer);
        }
Ejemplo n.º 5
0
 public void InitializeComponent() {
     if (_contentLoaded) {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/MyLocalPharmacy;component/View/Page2.xaml", System.UriKind.Relative));
     this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.ContentPanel = ((System.Windows.Controls.Grid)(this.FindName("ContentPanel")));
     this.myMap = ((Microsoft.Phone.Maps.Controls.Map)(this.FindName("myMap")));
     this.MyPushpin = ((Microsoft.Phone.Maps.Toolkit.Pushpin)(this.FindName("MyPushpin")));
 }
Ejemplo n.º 6
0
 public void InitializeComponent() {
     if (_contentLoaded) {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/PhoneToolkitSample8;component/Samples/MapsSample.xaml", System.UriKind.Relative));
     this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.Map = ((Microsoft.Phone.Maps.Controls.Map)(this.FindName("Map")));
     this.RouteDirectionsPushPin = ((Microsoft.Phone.Maps.Toolkit.Pushpin)(this.FindName("RouteDirectionsPushPin")));
     this.StoresMapItemsControl = ((Microsoft.Phone.Maps.Toolkit.MapItemsControl)(this.FindName("StoresMapItemsControl")));
     this.UserLocationMarker = ((Microsoft.Phone.Maps.Toolkit.UserLocationMarker)(this.FindName("UserLocationMarker")));
 }
Ejemplo n.º 7
0
 public void InitializeComponent()
 {
     if (_contentLoaded)
     {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/MyLocalPharmacy;component/View/Page2.xaml", System.UriKind.Relative));
     this.LayoutRoot   = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.ContentPanel = ((System.Windows.Controls.Grid)(this.FindName("ContentPanel")));
     this.myMap        = ((Microsoft.Phone.Maps.Controls.Map)(this.FindName("myMap")));
     this.MyPushpin    = ((Microsoft.Phone.Maps.Toolkit.Pushpin)(this.FindName("MyPushpin")));
 }
Ejemplo n.º 8
0
 protected void CreateNewPin(IVehicle vehicle)
 {
     var pushpin = new Pushpin();
     var mapLayer = new MapLayer();
     var overlay = new MapOverlay();
     pushpin.DataContext = vehicle;
     pushpin.Content = vehicle.Name;
     pushpin.Tap += pushpin_tap;
     mapLayer.Add(overlay);
     overlay.GeoCoordinate = new GeoCoordinate(vehicle.X, vehicle.Y);
     overlay.Content = pushpin;
     _mapController.Layers.Add(mapLayer);
 }
Ejemplo n.º 9
0
        private void PinMap(GeoCoordinate geoPosition, string locationName)
        {
            MyMap.SetView(geoPosition, 16, MapAnimationKind.Parabolic);
            var mapOverlayPin = new MapOverlay();
            var pin = new Pushpin()
            {
                Content = locationName
            };
            mapOverlayPin.Content = pin;
            mapOverlayPin.GeoCoordinate = geoPosition;

            var mapLayer = new MapLayer { mapOverlayPin };
            MyMap.Layers.Add(mapLayer);

            selectedCoordinate = geoPosition;
        }
Ejemplo n.º 10
0
 private static void drawMapMarker(OCStop stop, Color color, MapLayer mapLayer, Boolean action)
 {
     // Create a map marker
     Pushpin pin = new Pushpin();
     pin.Background = new SolidColorBrush(color);
     pin.GeoCoordinate = new GeoCoordinate(stop.stop_lat, stop.stop_lon);
     if (stop.stop_code.Length > 0)
     {
         pin.Name = stop.stop_code + " - " + stop.stop_name;
         if (action)
         {
             pin.Tap += mapPinTapped;
         }
         layMarker(pin, stop.stop_lat, stop.stop_lon, mapLayer);
     }
     
 }
Ejemplo n.º 11
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     MapLayer layer0 = new MapLayer();
     Pushpin pushpin1 = new Pushpin();
     pushpin1.GeoCoordinate = new GeoCoordinate(47.6097, -122.3331);
 
     MapOverlay overlay1 = new MapOverlay();
     pushpin1.Content = new Ellipse
     {
         Fill = new SolidColorBrush(Colors.Red),
         Width = 40,
         Height = 40
     };
     layer0.Add(overlay1);
     myMap.Layers.Add(layer0);
 }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            Trip currentTrip = ViewModel.Trip;
            if (currentTrip.IsActif)
                EndStack.Visibility = Visibility.Collapsed;
            else
                EndStack.Visibility = Visibility.Visible;
            //Bind les POI a la map
            ObservableCollection<DependencyObject> children = MapExtensions.GetChildren(statsMap);
            var obj = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl;
            if (obj.ItemsSource != null)
            {
                (obj.ItemsSource as IList).Clear();
                obj.ItemsSource = null;
            }
            obj.ItemsSource = (ViewModel.PointOfInterestList);

            //Ajout du départ
            MapLayer layer1 = new MapLayer();
            Pushpin pushpin1 = new Pushpin();
            pushpin1.GeoCoordinate = currentTrip.CoordinateDeparture;
            pushpin1.Background = new SolidColorBrush(Color.FromArgb(255, 105, 105, 105));
            pushpin1.Content = AppResources.AddTripDeparture;
            MapOverlay overlay1 = new MapOverlay();
            overlay1.Content = pushpin1;
            overlay1.GeoCoordinate = currentTrip.CoordinateDeparture;
            overlay1.PositionOrigin = new Point(0, 1);
            layer1.Add(overlay1);
            statsMap.Layers.Add(layer1);

            //Ajout de la destination
            MapLayer layer2 = new MapLayer();
            Pushpin pushpin2 = new Pushpin();
            pushpin2.GeoCoordinate = currentTrip.CoordinateDestination;
            pushpin2.Content = AppResources.AddTripArrival;
            pushpin2.Background = new SolidColorBrush(Color.FromArgb(255, 105, 105, 105));
            MapOverlay overlay2 = new MapOverlay();
            overlay2.Content = pushpin2;
            overlay2.GeoCoordinate = currentTrip.CoordinateDestination;
            overlay2.PositionOrigin = new Point(0, 1);
            layer2.Add(overlay2);
            statsMap.Layers.Add(layer2);
        }
Ejemplo n.º 13
0
        void myMap_Tap(object sender, GestureEventArgs e)
        {
            myMap.Layers.RemoveAt(0);

            point = e.GetPosition(myMap);
            point.X -= 25;
            point.Y -= 45;

            pushpin = new Pushpin();
            pushpin.Background = this.Resources["PhoneAccentBrush"] as SolidColorBrush;

            overlay = new MapOverlay();
            overlay.Content = pushpin;
            coordinate = myMap.ConvertViewportPointToGeoCoordinate(point);
            overlay.GeoCoordinate = coordinate;
            layer = new MapLayer();
            layer.Add(overlay);
            myMap.Layers.Add(layer);
        }
Ejemplo n.º 14
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (serviceClient != null) return;

            var loginProvider = (MobileServiceAuthenticationProvider) int.Parse(NavigationContext.QueryString["provider"]);
            var nickname = NavigationContext.QueryString["nick"];
            var group = NavigationContext.QueryString["group"];
            this.group.Text = group;

            serviceClient = new ServiceClient {AuthenticationProvider = loginProvider};
            var me = new Ninja
            {
                GroupName = group,
                NickName = nickname
            };

            var watcher = new GeoCoordinateWatcher();
            watcher.PositionChanged += (sender, args) => {
                var lat = /*args.Position.Location.Latitude*/ 55.7091;
                var lon = /*args.Position.Location.Longitude*/ 013.1982;
                var geoCoordinate = new GeoCoordinate(lat, lon);
                map.SetView(geoCoordinate, 6, MapAnimationKind.Linear);
                me.Latitude = lat;
                me.Longitude = lon;
                serviceClient.LocateNinjas(me, ninjas => Dispatcher.BeginInvoke(delegate
                {
                    var children = MapExtensions.GetChildren(map);
                    foreach (var ninja in ninjas)
                    {
                        var ninjaLocation = new GeoCoordinate(ninja.Latitude, ninja.Longitude);
                        var pushpin = new Pushpin { GeoCoordinate = ninjaLocation, Content = ninja.NickName };
                        children.Add(pushpin);
                    }
                    children.Add(new Pushpin {GeoCoordinate = geoCoordinate, Content = me.NickName, Background = new SolidColorBrush(Colors.Orange) });
                }));
                watcher.Stop();
            };
            watcher.Start();
        }
        public DetailsStation()
        {
            InitializeComponent();
            oneStationDetails = (Station_Item)PhoneApplicationService.Current.State["oneStationDetails"];
            positionUser = (GeoCoordinate)PhoneApplicationService.Current.State["positionUser"];

            if (oneStationDetails != null)
            {
                stationNum.Text = oneStationDetails.Name;
                txtAdress.Text = oneStationDetails.Wcom;
            }

            //carte en mode "route" par défaut
            Map.CartographicMode = MapCartographicMode.Road;

            //zoom sur la station
            oneStationDetails.Lat = oneStationDetails.Lat.Replace('.', ',');
            double lat = Convert.ToDouble(oneStationDetails.Lat);
            oneStationDetails.Lng = oneStationDetails.Lng.Replace('.', ',');
            double lng = Convert.ToDouble(oneStationDetails.Lng);

            posStation = new GeoCoordinate(lat, lng);
            Map.ZoomLevel = 17;
            Map.Center = posStation;

            //point d'intérêt
            var elts = MapExtensions.GetChildren(Map);
            Pushpin pushpin = new Pushpin();
            pushpin.Content = oneStationDetails.Name;
            MapExtensions.Add(elts, pushpin, posStation);

            //ajout des informations pour les piétons (escaliers)
            Map.PedestrianFeaturesEnabled = true;

            //itinéraire
            coordonnesTrajet = new List<GeoCoordinate>();
        }
Ejemplo n.º 16
0
        private async void AddPushpins(IEnumerable<AddressViewModel> addresses)
        {
            await Task.Run(() =>
            {
                MapLayer layer = new MapLayer();
                foreach (AddressViewModel address in addresses)
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            MapOverlay overlay = new MapOverlay();
                            Pushpin pushpin = new Pushpin() { Content = address.Name };
                            pushpin.Tap += (sender, e) => { address.ShowDetails.Execute(null); };
                            overlay.Content = pushpin;
                            overlay.GeoCoordinate = address.Coordinate;

                            layer.Add(overlay);
                        });
                }
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        addressMap.Layers.Add(layer);
                    });
            });
        }
Ejemplo n.º 17
0
        private void PlaceCurrentLocationPushpin(double latitude, double longitude)
        {
            this.mapLocation.Layers.Clear();

            MapLayer layer = new MapLayer();
            this.mapLocation.Layers.Add(layer);

            TextBlock tb = new TextBlock();
            tb.TextAlignment = TextAlignment.Center;
            tb.Text = "Current Location";

            Pushpin pp = new Pushpin();
            pp.Content = tb;
            pp.Margin = new Thickness(0, -60, 0, 0);

            MapOverlay mo = new MapOverlay();
            mo.Content = pp;
            mo.GeoCoordinate = new System.Device.Location.GeoCoordinate(latitude, longitude);

            layer.Add(mo);
        }
Ejemplo n.º 18
0
        private void ShowCrisisOnTheMap()
        {
            try
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                if (App.place != null)
                {
                    sb.Append("Place: ").Append(App.place).Append("\n");
                }
                sb.Append("Subject: ").Append(App.subject).Append("\n");
                sb.Append("Date: ").Append(App.dateTime);
                sampleMap.Center = new GeoCoordinate(App.latitude, App.longitude);
                sampleMap.ZoomLevel = 8;
                sampleMap.CartographicMode = MapCartographicMode.Aerial;
                if (App.alert_level == "Green")
                {
                    pin = new Pushpin
                    {
                        GeoCoordinate = new GeoCoordinate(App.latitude,App.longitude),
                        Background= new SolidColorBrush(Colors.Green),
                        Content = sb.ToString(),
                        Foreground= new SolidColorBrush(Colors.Black)
                    };
                }
                else if (App.alert_level == "Orange")
                {
                    pin = new Pushpin
                    {
                        GeoCoordinate = new GeoCoordinate(App.latitude, App.longitude),
                        Background = new SolidColorBrush(Colors.Orange),
                        Content = sb.ToString(),
                        Foreground = new SolidColorBrush(Colors.Black)
                    };
                }
                else
                {
                   pin = new Pushpin
                    {
                        GeoCoordinate = new GeoCoordinate(App.latitude, App.longitude),
                        Background = new SolidColorBrush(Colors.Red),
                        Content = sb.ToString(),
                        Foreground = new SolidColorBrush(Colors.Black)
                    };

                }
                MapOverlay overlay = new MapOverlay
                {
                    GeoCoordinate = new GeoCoordinate(App.latitude,App.longitude),
                    Content = new Ellipse
                    {
                        Fill = new SolidColorBrush(Colors.Red),
                        Width = 40,
                        Height = 40
                    }
                };

                overlay.Content = pin;
                MapLayer layer = new MapLayer();
                layer.Add(overlay);
                sampleMap.Layers.Add(layer);

            }
            catch(Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Ejemplo n.º 19
0
        public static async Task AddLocation(Microsoft.Phone.Maps.Controls.Map myMap, Microsoft.Phone.Controls.PhoneTextBox myTextBox, System.Windows.Input.GestureEventArgs e, double latitude, double longitude, bool completeAddress = false, string pinContent = "")
        {
            ReverseGeocodeQuery query;
            List<MapLocation> mapLocations;
            string pushpinContent = "";
            MapLocation mapLocation;

            query = new ReverseGeocodeQuery();
            if (e != null)
                query.GeoCoordinate = myMap.ConvertViewportPointToGeoCoordinate(e.GetPosition(myMap));
            else
                query.GeoCoordinate = new GeoCoordinate(latitude, longitude);

            mapLocations = (List<MapLocation>)await query.GetMapLocationsAsync();
            mapLocation = mapLocations.FirstOrDefault();

            if (mapLocation != null && !String.IsNullOrEmpty(mapLocation.Information.Address.Country))
            {
                MapLayer pinLayout = new MapLayer();
                Pushpin MyPushpin = new Pushpin();
                MapOverlay pinOverlay = new MapOverlay();
                if (myMap.Layers.Count > 0)
                {
                    myMap.Layers.RemoveAt(myMap.Layers.Count - 1);
                }

                myMap.Layers.Add(pinLayout);

                MyPushpin.GeoCoordinate = mapLocation.GeoCoordinate;


                pinOverlay.Content = MyPushpin;
                pinOverlay.GeoCoordinate = mapLocation.GeoCoordinate;
                pinOverlay.PositionOrigin = new Point(0, 1);
                pinLayout.Add(pinOverlay);

                if (!completeAddress)
                    pushpinContent = getAddress(mapLocation);
                else
                    pushpinContent = getCompleteAddress(mapLocation);

                if (!string.IsNullOrEmpty(pinContent))
                    pushpinContent = pinContent;

                MyPushpin.Content = pushpinContent.Trim();
                if (myTextBox != null)
                    myTextBox.Text = MyPushpin.Content.ToString();
            }
        }
Ejemplo n.º 20
0
        private void UpdateMap()
        {
            QuakeMap.Layers.Clear();
            // Select only quakes above the settings magnitude
            // The OrderBy means that higher magnitude quakes will be pinned on top OrderBy(s => s.Magnitude)
            double minWarningMagnitude = AppSettingsForPage.MinimumWarningMagnitudeSetting;
            if (QuakeContainer.Quakes != null)
            {
                MapLayer layer = new MapLayer();
                // Use "reverse" here so newer quakes are on top.
                foreach (var q in QuakeContainer.Quakes.Reverse())
                {
                    Pushpin pin = new Pushpin()
                    {
                        GeoCoordinate = q.Location,
                        Content = q.FormattedMagnitude,
                        DataContext = q,
                    };
                    pin.Tap += QuakeItem_Tap;
                    if (q.Magnitude >= minWarningMagnitude)
                        pin.Background = Application.Current.Resources["PhoneAccentBrush"] as SolidColorBrush;
                    MapOverlay overlay = new MapOverlay();
                    overlay.Content = pin;
                    overlay.GeoCoordinate = q.Location;
                    overlay.PositionOrigin = new Point(0, 1);

                    layer.Add(overlay);

                }
                QuakeMap.Layers.Add(layer);
            }
        }
        void Utility_QueryComplete(object sender, QueryCompletedEventArgs<IList<MapLocation>> e)
        {
            try
            {
                if (!String.IsNullOrEmpty(NameTextBox.Text) && e.Result.Count == 0)
                {
                    MessageBox.Show(string.Format(AppResources.InvalideSearch, NameTextBox.Text), AppResources.Warning, MessageBoxButton.OK);
                    return;
                }

                GeoCoordinate coord = new GeoCoordinate();
                foreach (var item in e.Result)
                {
                    coord = item.GeoCoordinate;
                    NameTextBox.Text = Utils.Utility.getCompleteAddress(item.Information.Address);
                }

                MapLayer pinLayout = new MapLayer();
                Pushpin MyPushpin = new Pushpin();
                MapOverlay pinOverlay = new MapOverlay();
                if (myMap.Layers.Count > 0)
                    myMap.Layers.RemoveAt(myMap.Layers.Count - 1);

                myMap.Layers.Add(pinLayout);

                MyPushpin.GeoCoordinate = coord;

                pinOverlay.Content = MyPushpin;
                pinOverlay.GeoCoordinate = MyPushpin.GeoCoordinate;
                pinOverlay.PositionOrigin = new Point(0, 1);
                pinLayout.Add(pinOverlay);
                MyPushpin.Content = AppResources.MyTour;

                ViewModel.Tour.Latitude = coord.Latitude;
                ViewModel.Tour.Longitude = coord.Longitude;
            }
            catch (Exception ex) { throw ex; }
        }
        private void updateMap(CheckMapp.Utils.PlaceNearToMap.PlacesList aWiKIAPIResponse)
        {
            int totalRecords = aWiKIAPIResponse.PlaceList.Count();
            MyMap.Visibility = System.Windows.Visibility.Visible;

            try
            {
                ObservableCollection<CheckMapp.Utils.PlaceNearToMap.PlaceNearMap> placeToMapObjs = new ObservableCollection<CheckMapp.Utils.PlaceNearToMap.PlaceNearMap>();
                for (int index = 0; index < totalRecords; index++)
                {
                    placeToMapObjs.Add(new CheckMapp.Utils.PlaceNearToMap.PlaceNearMap()
                    {
                        Coordinate = new GeoCoordinate(Convert.ToDouble(aWiKIAPIResponse.PlaceList.ElementAt(index).Latitude, CultureInfo.InvariantCulture),
                                        Convert.ToDouble(aWiKIAPIResponse.PlaceList.ElementAt(index).Longitude, CultureInfo.InvariantCulture)),
                        Info = aWiKIAPIResponse.PlaceList.ElementAt(index).Title,
                        Summary = aWiKIAPIResponse.PlaceList.ElementAt(index).Summary

                    });
                }
                removeTempMapLayer();

                int countPOI = 0;
                foreach (CheckMapp.Utils.PlaceNearToMap.PlaceNearMap PlaceNear in placeToMapObjs)
                {
                    // If the set doesn't contains an element latitude+longitude we can show it trough pushPin nearby the phone location
                    if (!ViewModel.PointOfInterestList.Any(x => x.Latitude == PlaceNear.Coordinate.Latitude && x.Longitude == PlaceNear.Coordinate.Longitude))
                    {
                        MapLayer pinLayout = new MapLayer();
                        Pushpin MyPushpin = new Pushpin();
                        MapOverlay pinOverlay = new MapOverlay();

                        MyMap.Layers.Add(pinLayout);

                        MyPushpin.GeoCoordinate = PlaceNear.Coordinate;

                        pinOverlay.Content = MyPushpin;
                        pinOverlay.GeoCoordinate = PlaceNear.Coordinate;
                        pinOverlay.PositionOrigin = new Point(0, 1);
                        pinLayout.Add(pinOverlay);

                        MyPushpin.Content = PlaceNear.Info.Trim();

                        MyPushpin.Background = new SolidColorBrush(Color.FromArgb(255, 105, 105, 105));
                        MyPushpin.Tap += MyPushpin_Tap;
                        MyPushpin.Tag = PlaceNear;

                        countPOI++;
                    }
                }

                MessageBox.Show(String.Format(AppResources.ResultPOI, countPOI), AppResources.PlaceNearYou, MessageBoxButton.OK);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception occured while updating map : " + ex.Message);
            }
        }
Ejemplo n.º 23
0
        private void LoadMap()
        {
            try
            {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("Date: ").Append(map_datetime.ToString());
            sampleMap.Center = new GeoCoordinate(map_latitude, map_longitude);
            if (map_alertlevel == "Green")
            {
                    pin = new Pushpin
                    {
                        GeoCoordinate = new GeoCoordinate(map_latitude,map_longitude),
                        Background= new SolidColorBrush(Colors.Green),
                        Content = sb.ToString(),
                        Foreground= new SolidColorBrush(Colors.Black)
                    };
                }
                else if (map_alertlevel == "Orange")
                {
                    pin = new Pushpin
                    {
                        GeoCoordinate = new GeoCoordinate(map_latitude, map_longitude),
                        Background = new SolidColorBrush(Colors.Orange),
                        Content = sb.ToString(),
                        Foreground = new SolidColorBrush(Colors.Black)
                    };
                }
                else if(map_alertlevel=="Red")
                {
                   pin = new Pushpin
                    {
                        GeoCoordinate = new GeoCoordinate(map_latitude, map_longitude),
                        Background = new SolidColorBrush(Colors.Red),
                        Content = sb.ToString(),
                        Foreground = new SolidColorBrush(Colors.Black)
                    };

                }
                MapOverlay overlay = new MapOverlay
                {
                    GeoCoordinate = new GeoCoordinate(map_latitude, map_longitude),
                    Content = new Ellipse
                    {
                        Fill = new SolidColorBrush(Colors.Red),
                        Width = 40,
                        Height = 40
                    }
                };

                overlay.Content = pin;
                MapLayer layer = new MapLayer();
                layer.Add(overlay);
                sampleMap.Layers.Add(layer);

            }
            catch(Exception e)
            {

            }
        }
Ejemplo n.º 24
0
        private void SetPushpin(GeoCoordinate coordinate) {
            selectedPushpin = new Pushpin() {Content = "Share", GeoCoordinate = coordinate};

            selectedPushpinOverlay.Content = selectedPushpin;
            selectedPushpinOverlay.GeoCoordinate = coordinate;
        }
Ejemplo n.º 25
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     pageName.Text = current.getName();
    // List<PlaceViewModel> Item = new List<PlaceViewModel>();
  //   Item.Add(new PlaceViewModel()
 //    {
     string price = "";
     for (int i = 0; i < current.getPrice();i++)
     {
         price += "₴";
     }
         Image.Source = new BitmapImage(new Uri(current.getImageName(), UriKind.Absolute));
         Price.Text = price;
         Description.Text = current.getDescription();
         Web.Content = getShortWebUrl(current.getWeb());
         Adress.Text = current.getStreet();
         SubwayColor.Background = new SolidColorBrush(current.getSubway().getColor());
         SubwayName.Text = current.getSubway().getName();
  //   });
 //    list.DataContext = Item; 
         localMap.Center = current.getCoordinates();
         localMap.ZoomLevel = 15;
         Pushpin pin = new Pushpin()
                 {
                     Content = current.getName(),
                     Margin = new Thickness(0,-60,0,0)
                 };
         MapOverlay overlay = new MapOverlay()
         {
             GeoCoordinate = current.getCoordinates(),
             Content = pin    
         };
         MapLayer layer = new MapLayer();
         layer.Add(overlay);
         localMap.Layers.Add(layer);
 }
Ejemplo n.º 26
0
        //Method to draw each pushin to the map
        private void DrawPushPin(GeoCoordinate myGeoPosition, string pushPinName, bool clean = false)
        {
            var pp = new Pushpin { Content = pushPinName };
            var overlay = new MapOverlay { Content = pp };

            //if map isn't clear,then clear
            if (clean)
                layer1.Clear();


            layer1.Add(overlay);
            layer1[layer1.Count - 1].GeoCoordinate = MyGeoCoordPosition;

            MyMap.Center = myGeoPosition;
            MyMap.ZoomLevel = 16;
        }
        /// <summary>
        /// Method to set Map
        /// </summary>
        /// <param name="coordinateCollectionSub"></param>
        /// <param name="count"></param>
        private void SetMap(GPSurgeriesCollection coordinateCollectionSub, int count)
        {
            if (count == 0)
            {
                GPSurgeriesFeedData coordinate = coordinateCollectionSub.First();
                if (!IsFromSaved)
                {
                    MyMap.Center = new GeoCoordinate(Convert.ToDouble(coordinate.Latitude), Convert.ToDouble(coordinate.Longitude));

                }
                else
                {
                    MyMap.Center = App.LocalServiceCentreCoordinates;
                    MyMap.ZoomLevel = App.LocalServiceZoomLevel;
                    IsFromSaved = false;
                }

            }

            foreach (GPSurgeriesFeedData coordinate in coordinateCollectionSub)
            {
                IsPlotted = true;

                Pushpin pushpin = new Pushpin();

                pushpin.Content = " +";
                pushpin.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(PushpinTap);

                MapLayer layer = new MapLayer();
                MapOverlay overlay = new MapOverlay();

                pushpin.Tag = coordinate.Name + "_" + coordinate.PostCode + "_" + coordinate.Addressline1 + "_" + coordinate.Addressline2 + "_" + coordinate.Addressline3 + "_" + coordinate.Addressline4 + "_" + coordinate.Addressline5 + "_" + coordinate.Telephone + "_" + coordinate.Latitude + "_" + coordinate.Longitude;

                overlay.Content = pushpin;

                overlay.GeoCoordinate = new GeoCoordinate(Convert.ToDouble(coordinate.Latitude), Convert.ToDouble(coordinate.Longitude));
                overlay.PositionOrigin = new Point(0.0, 1.0);
                layer.Add(overlay);
                MyMap.Layers.Add(layer);
            }
        }
Ejemplo n.º 28
0
        //Location loc;
        public list()
        {
            InitializeComponent();
            String xmlStr = (String)PhoneApplicationService.Current.State["stations"];
            XDocument xmlDoc = XDocument.Parse(xmlStr);

            Carte = new Map();
            Carte.ZoomLevel = 10.0;
            ContentMap.Children.Add(Carte);
            int inc = 0;
            List<XElement> listOfStands = xmlDoc.Descendants("stand").ToList();
            foreach (XElement item in listOfStands)
            {

                if (int.Parse(item.Element("disp").Value) == 1)
                {
                    Stand std = new Stand();

                    if (item.HasAttributes)
                    {

                        std.Nom = item.Attribute("name").Value;
                        std.Id = int.Parse(item.Attribute("id").Value);
                    }

                    //Descendants
                    if (item.HasElements)
                    {
                        //MessageBox.Show(item.Element("lng").Value);
                        //Double test = Double.Parse(item.Element("lng").Value);
                        if (item.Element("wcom") != null) std.Add = item.Element("wcom").Value;
                        if (item.Element("lng") != null) std.Lng = Convert.ToDouble(item.Element("lng").Value.Replace(".",","));
                        if (item.Element("lat") != null) std.Lat = Convert.ToDouble(item.Element("lat").Value.Replace(".",","));
                        if (item.Element("ab") != null) std.Ab = int.Parse(item.Element("ab").Value);
                        if (item.Element("ac") != null) std.Ac = int.Parse(item.Element("ac").Value);
                        if (item.Element("ap") != null) std.Ap = int.Parse(item.Element("ap").Value);
                        if (item.Element("tc") != null) std.Tc = int.Parse(item.Element("tc").Value);

                        if (std.Add != null)
                        {
                            std.Add = std.Add.Replace("+", " ");
                            std.Add = std.Add.Replace("%c2", "°");
                        }
                        loc = new GeoCoordinate();
                        loc.Longitude = std.Lng;
                        loc.Latitude = std.Lat;
                        Pushpin pin = new Pushpin();

                        ToolTipService.SetToolTip(pin, "station n°" + std.Id + "\n" + std.Ap + " places disponible" + "\n" + std.Ab + " vélos disponible");

                        pin.TabIndex = inc;

                        pin.GeoCoordinate = loc;
                        pin.Name = inc.ToString();

                        Carte.Center = loc;
                        pin.Tap += pin_event;

                        ImageBrush imgBrush = new ImageBrush();
                        imgBrush.Stretch = System.Windows.Media.Stretch.UniformToFill;
                        imgBrush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"velo_bleu.png", UriKind.Relative));

                        Grid MyGrid = new Grid();
                        MyGrid.RowDefinitions.Add(new RowDefinition());
                        MyGrid.RowDefinitions.Add(new RowDefinition());
                        MyGrid.Background = new SolidColorBrush(Colors.Transparent);

                        Rectangle MyRectangle = new Rectangle();
                        MyRectangle.Fill = imgBrush;
                        MyRectangle.Height = 52;
                        MyRectangle.Width = 85;
                        MyRectangle.Name = inc.ToString();
                        MyRectangle.SetValue(Grid.RowProperty, 0);
                        MyRectangle.SetValue(Grid.ColumnProperty, 0);
                        MyRectangle.Tap += pin_event;
                        MyGrid.Children.Add(MyRectangle);

                        MapLayer layer = new MapLayer();
                        MapOverlay overlay = new MapOverlay();
                        overlay.Content = MyGrid;
                        overlay.GeoCoordinate = pin.GeoCoordinate;
                        layer.Add(overlay);

                        Carte.Layers.Add(layer);
                        inc++;
                    }
                    stands.Add(std);
                }

            }
            // standList.DataContext = stands;
        }
Ejemplo n.º 29
0
        private void AddPushpin(GeoCoordinate coordinate, string name) {
            Pushpin pushpin = new Pushpin();
            pushpin.GeoCoordinate = coordinate;
            pushpin.Content = name;

            MapOverlay newOverlay = new MapOverlay();
            newOverlay.Content = pushpin;
            newOverlay.GeoCoordinate = coordinate;

            MapLayer newLayer = new MapLayer();
            newLayer.Add(newOverlay);

            Map.Layers.Add(newLayer);

        }
      private async void mapControl_Hold(object sender, System.Windows.Input.GestureEventArgs e)
      {
         status.Text = "querying for address...";

         var point = e.GetPosition(mapControl);
         var coordinate = mapControl.ConvertViewportPointToGeoCoordinate(point);

         var pushpin = new Pushpin
         {
            GeoCoordinate = coordinate,
            Content = ++pinNumber,
         };
         MapExtensions.GetChildren(mapControl).Add(pushpin);

         position.Text = string.Format("Latitude: {0}\nLongitude: {1}\n",
             FormatCoordinate(coordinate.Latitude, 'N', 'S'),
             FormatCoordinate(coordinate.Longitude, 'E', 'W'));

         ReverseGeocodeQuery query = new ReverseGeocodeQuery { GeoCoordinate = coordinate };
         IList<MapLocation> results = await query.GetMapLocationsAsync();
         position.Text += string.Format("{0} locations found.\n", results.Count);
         MapLocation location = results.FirstOrDefault();
         if (location != null)
         {
            position.Text += FormatAddress(location.Information.Address);
         }
         status.Text += "complete";
      }
Ejemplo n.º 31
0
        private void updatePins()
        {
            var winPhoneMapView = Control;
            var formsMap = (Xam.Plugin.MapExtend.Abstractions.MapExtend)Element;

            var items = formsMap.Pins;
            var toRemove = new List<MapLayer>();
            foreach (var item in winPhoneMapView.Layers)
            {
                if (item.Count > 0)
                    if (item[0].Content is Pushpin)
                        toRemove.Add(item);
            }
            foreach (var item in toRemove)
            {
                winPhoneMapView.Layers.Remove(item);
            }

            foreach (var item in items)
            {
                MapLayer myLayer = new MapLayer();
                var markerWithIcon = new Pushpin();
                markerWithIcon.GeoCoordinate = new GeoCoordinate(item.Position.Latitude, item.Position.Longitude);
                markerWithIcon.Content = (string.IsNullOrWhiteSpace(item.Label) ? "-" : item.Label);

                //markerWithIcon.AllowDrop = true;

                MapOverlay myOverlay = new MapOverlay()
                {
                    GeoCoordinate = markerWithIcon.GeoCoordinate,
                    PositionOrigin = new System.Windows.Point(0.0, 1.0),
                    Content = markerWithIcon
                };

                myLayer.Add(myOverlay);

                winPhoneMapView.Layers.Add(myLayer);
            }
        }
 public PushpinsGroup(Pushpin pushpin, Point location)
 {
     _pushpins.Add(pushpin);
     MapLocation = location;
 }