private void showlocations() { foreach (Place p in _vm.Places) { Grid MyGrid = new Grid(); MyGrid.RowDefinitions.Add(new RowDefinition()); MyGrid.RowDefinitions.Add(new RowDefinition()); MyGrid.Background = new SolidColorBrush(Colors.Transparent); BitmapImage bmi = new BitmapImage(new Uri("/Assets/pushpinPhone.png", UriKind.Relative)); Image img = new Image(); img.Tag = (p); img.Source = bmi; MyGrid.Children.Add(img); //Creating a MapOverlay and adding the Grid to it. MapOverlay MyOverlay = new MapOverlay(); MyOverlay.Content = MyGrid; MyOverlay.GeoCoordinate = new GeoCoordinate(p.Latitude, p.Longitude); MyOverlay.PositionOrigin = new Point(0, 0.5); //Creating a MapLayer and adding the MapOverlay to it MapLayer MyLayer = new MapLayer(); MyLayer.Add(MyOverlay); mapWithMyLocation.Layers.Add(MyLayer); } }
private void UpdateMap() { Map map = _view.Map; map.SetView(_gpsLocation, 15); map.Layers.Clear(); MapLayer layer = new MapLayer(); foreach (var r in Restaurants) { MapOverlay overlay = new MapOverlay(); overlay.Content = new Pushpin() { Content = r.Name }; overlay.GeoCoordinate = r.GeoCoordinate; layer.Add(overlay); } layer.Add(new MapOverlay() { Content = new UserLocationMarker(), GeoCoordinate = _gpsLocation }); map.Layers.Add(layer); }
public ComoLlegar() { InitializeComponent(); var markerLayer = new MapLayer(); var posicion = new GeoCoordinate(-34.5584560886206, -58.4167098999023); var pushpin = new MapOverlay() { GeoCoordinate = posicion, }; markerLayer.Add(pushpin); Mapa.Layers.Add(markerLayer); Mapa.Center = posicion; Mapa.ZoomLevel = 14; if (App.Configuration.IsLocationEnabled && PositionService.GetCurrentLocation().Location != null) { pushpin = new MapOverlay { GeoCoordinate = PositionService.GetCurrentLocation().Location, ContentTemplate = App.Current.Resources["locationPushpinTemplate"] as DataTemplate, }; markerLayer.Add(pushpin); Mapa.SetView(Mapa.CreateBoundingRectangle()); } }
public void samplecodetwo() { MapLayer layer0 = new MapLayer(); MapOverlay overlay0 = new MapOverlay(); MapOverlay overlay1 = new MapOverlay(); MapOverlay overlay2 = new MapOverlay(); Pushpin pushpin0 = new Pushpin(); Pushpin pushpin1 = new Pushpin(); Pushpin pushpin2 = new Pushpin(); //Pushpin pushpin0 = (Pushpin)this.FindName("pushpin0"); //Pushpin pushpin0 = MapExtensions.GetChildren(myMap).OfType<Pushpin>().First(p => p.Name == "pushpin0"); //if (pushpin0 == null) { pushpin0 = new Pushpin(); } pushpin0.GeoCoordinate = new GeoCoordinate(37.228510, -80.422860); pushpin1.GeoCoordinate = new GeoCoordinate(37.226399, -80.425271); pushpin2.GeoCoordinate = new GeoCoordinate(37.228900, -80.427450); overlay0.GeoCoordinate = new GeoCoordinate(37.228510, -80.422860); overlay0.Content = pushpin0; overlay1.Content = pushpin1; overlay2.Content = pushpin2; layer0.Add(overlay0); layer0.Add(overlay1); layer0.Add(overlay2); // Add the layer with the pins in to the map map_Fullscreen.Layers.Add(layer0); //ContentPanel.Children.Add(myMap); }
private void AddResultToMap(GeoCoordinate location) { if (PolyCircle != null) { map1.MapElements.Remove(PolyCircle); PolyCircle = null; } if (markerLayer != null) { map1.Layers.Remove(markerLayer); markerLayer = null; } markerLayer = new MapLayer(); map1.Layers.Add(markerLayer); oneMarker = new MapOverlay(); oneMarker.GeoCoordinate = location; Ellipse Circhegraphic = new Ellipse(); Circhegraphic.Fill = new SolidColorBrush(Colors.Yellow); Circhegraphic.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red); Circhegraphic.StrokeThickness = 30; Circhegraphic.Opacity = 0.8; Circhegraphic.Height = 80; Circhegraphic.Width = 80; oneMarker.Content = Circhegraphic; oneMarker.PositionOrigin = new Point(0.5, 0.5); Circhegraphic.MouseLeftButtonDown += textt_MouseLeftButtonDown; DoCreateTheAreaCircle(); if (PolyCircle != null && PolyCircle.Path != null) { twoMarker = new MapOverlay(); twoMarker.GeoCoordinate = PolyCircle.Path[0]; Ellipse Cirche2 = new Ellipse(); Cirche2.Fill = new SolidColorBrush(Colors.Yellow); Cirche2.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red); Cirche2.StrokeThickness = 15; Cirche2.Opacity = 0.8; Cirche2.Height = 40; Cirche2.Width = 40; twoMarker.Content = Cirche2; twoMarker.PositionOrigin = new Point(0.5, 0.5); Cirche2.MouseLeftButtonDown += area_MouseLeftButtonDown; markerLayer.Add(twoMarker); } markerLayer.Add(oneMarker); map1.Center = oneMarker.GeoCoordinate; }
private void mapPostItinerary_Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (endPointOverlay != null) { myLocationLayer.Remove(endPointOverlay); } GeoCoordinate asd = this.mapPostItinerary.ConvertViewportPointToGeoCoordinate(e.GetPosition(this.mapPostItinerary)); //MessageBox.Show("lat: " + asd.Latitude + "; long: " + asd.Longitude); //dat pushpin endPointOverlay = MarkerDraw.DrawMapMarker(asd); // Create a MapLayer to contain the MapOverlay. myLocationLayer.Add(endPointOverlay); // Add the MapLayer to the Map. mapPostItinerary.Layers.Remove(myLocationLayer); mapPostItinerary.Layers.Add(myLocationLayer); //mapPostItinerary.Layers.Remove() //hien thi thong tin diem den tren textbox geoQ.GeoCoordinate = asd; geoQ.QueryAsync(); }
private void PintarMapa() { ServiceManager.Client.Metadata.GetAllAsync((Dictionary <string, Buddy.MetadataItem> arg1, BuddyCallbackParams arg2) => { MapLayer layer = new MapLayer(); for (var i = 0; i < arg1.Keys.Count; i++) { string userid = arg1.ToArray()[i].Value.Value; if (userid == ServiceManager.User.Token) { double x = arg1.ToArray()[i].Value.Latitude; double y = arg1.ToArray()[i].Value.Longitude; ServiceManager.Client.Metadata.FindAsync((Dictionary <string, Buddy.MetadataItem> arg3, BuddyCallbackParams arg4) => { for (var a = 0; a < arg3.Keys.Count; a++) { string userid2 = arg3.ToArray()[a].Value.Value; if (userid2 != ServiceManager.User.Token) { double x2 = arg3.ToArray()[a].Value.Latitude; double y2 = arg3.ToArray()[a].Value.Longitude; MapOverlay overlay2 = new MapOverlay { GeoCoordinate = new GeoCoordinate(x2, y2), Content = new Ellipse { Fill = new SolidColorBrush(Colors.Blue), Width = 10, Height = 10 } }; layer.Add(overlay2); } } }, searchDistanceMeters: 10, latitude: x, longitude: y, numberOfResults: 20, withKey: null, withValue: null, updatedMinutesAgo: -1, valueMin: 0, valueMax: 100, searchAsFloat: false, sortAscending: false, disableCache: false, state: null); MapOverlay overlay = new MapOverlay { GeoCoordinate = new GeoCoordinate(x, y), Content = new Ellipse { Fill = new SolidColorBrush(Colors.Red), Width = 10, Height = 10 } }; layer.Add(overlay); } } map.Layers.Add(layer); }); }
public MapPickPage() { InitializeComponent(); MapLayer mainLayer = new MapLayer(); mainLayer.Add(selectedPushpinOverlay); mainLayer.Add(myPositionOverlay); Map.Layers.Add(mainLayer); Map.ZoomLevel = 16; GetMyMapLocationAsync(); }
void GetDondeComprar() { ResetUI(); if (!NetworkInterface.GetIsNetworkAvailable()) { ConnectionError.Visibility = Visibility.Visible; Dispatcher.BeginInvoke(() => MessageBox.Show("Ha habido un error intentando acceder a los nuevos datos o no hay conexiones de red disponibles.\nPor favor asegúrese de contar con acceso de red y vuelva a intentarlo.")); return; } GeoPosition <GeoCoordinate> currentLocation = PositionService.GetCurrentLocation(); if (!App.Configuration.IsLocationEnabled) { Dispatcher.BeginInvoke(() => MessageBox.Show("Para buscar, por favor, active la función de localización en la configuración de la aplicación.")); return; } if (currentLocation == null) { Dispatcher.BeginInvoke(() => MessageBox.Show("Para buscar, por favor, active la función de localización.")); return; } ProgressBar.Show("Buscando más cercanos..."); if (App.Configuration.IsLocationEnabled && PositionService.GetCurrentLocation().Location != null) { var pushpin = new MapOverlay { GeoCoordinate = PositionService.GetCurrentLocation().Location, ContentTemplate = Application.Current.Resources["locationPushpinTemplate"] as DataTemplate, }; _pointsLayer.Add(pushpin); Mapa.SetView(Mapa.CreateBoundingRectangle()); } if (ViewModel.Puntos.Count == 0) { Refreshing.Visibility = Visibility.Visible; } SetApplicationBarEnabled(false); CancelarRequest(); var param = new Dictionary <string, object> { { "cant", 10 }, }; var client = new HttpClient(); _httpReq = client.Get(string.Format("/api/{0}sube", ViewModel.Tipo).ToApiCallUri(param)); _httpReq.BeginGetResponse(HTTPWebRequestCallBack, _httpReq); }
public async void CarregaMapa() { Geolocator geo = new Geolocator(); if (geo.LocationStatus != PositionStatus.Disabled) { Geoposition pos = await geo.GetGeopositionAsync(); MapOverlay MyOverlay = new MapOverlay(); Image image = new Image(); image.Height = 100; image.Width = 100; image.Source = new BitmapImage(new Uri("/Assets/pin.png", UriKind.Relative)); MyOverlay.Content = image; MyOverlay.GeoCoordinate = new GeoCoordinate(pos.Coordinate.Latitude, pos.Coordinate.Longitude); MapLayer MyLayer = new MapLayer(); MyLayer.Add(MyOverlay); localPedido.Center = MyOverlay.GeoCoordinate; localPedido.ZoomLevel = 15; localPedido.Layers.Clear(); localPedido.Layers.Add(MyLayer); } }
private void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { Friend addedFriend = (lstFriends.Items.Last() as Friend); layers = new MapLayer(); overlay = new MapOverlay(); image = new BitmapImage(); image.UriSource = (new Uri(addedFriend.Picture, UriKind.Absolute)); brush = new ImageBrush(); brush.ImageSource = image; ellipse = new Ellipse(); ellipse.DataContext = addedFriend; ellipse.Hold += ellipse_Hold; ellipse.Height = 100; ellipse.Width = 100; ellipse.Fill = brush; overlay.GeoCoordinate = new GeoCoordinate(addedFriend.LastPosition.Latitude, addedFriend.LastPosition.Longitude); overlay.Content = ellipse; layers.Add(overlay); myMap.Layers.Add(layers); } }
private void AddMapIcon(Map map, GeoCoordinate geoPosition) { // 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; // Create a MapOverlay to contain the circle. MapOverlay myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = myCircle; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = geoPosition; // Create a MapLayer to contain the MapOverlay. MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); // Add the MapLayer to the Map. maploc.Layers.Add(myLocationLayer); }
private async void ShowMyLocationOnTheMap() { // Get my current location. Geolocator myGeolocator = new Geolocator(); Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync(); Geocoordinate myGeocoordinate = myGeoposition.Coordinate; GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate); // 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; // Create a MapOverlay to contain the circle. MapOverlay myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = myCircle; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = myGeoCoordinate; // Create a MapLayer to contain the MapOverlay. MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); // Add the MapLayer to the Map. Haritam.Layers.Add(myLocationLayer); }
void Seanslar_getCompleted(seanslar sender) { loader.IsIndeterminate = false; PanoramaRoot.Title = sender.SalonBilgisi.name; pItem1.DataContext = sender.SalonBilgisi; listFilmler.ItemsSource = sender.SalonBilgisi.movies; if (sender.SalonBilgisi.latitude.ToString() != "false") { SalonCoordinate = new GeoCoordinate(double.Parse(sender.SalonBilgisi.latitude), double.Parse(sender.SalonBilgisi.longitude)); myMap.SetView(SalonCoordinate, 17); pinpoint_salon newPin = new pinpoint_salon(); MapOverlay newOverlay = new MapOverlay(); newOverlay.Content = newPin; newOverlay.GeoCoordinate = SalonCoordinate; newOverlay.PositionOrigin = new Point(0, 0); MapLayer MyLayer = new MapLayer(); MyLayer.Add(newOverlay); myMap.Layers.Add(MyLayer); } else { myMap.Visibility = Visibility.Collapsed; recMap.Visibility = System.Windows.Visibility.Collapsed; } }
private async void ShowMyLocationOnTheMap() { // Get my current location. Geolocator myGeolocator = new Geolocator(); Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync(); Geocoordinate myGeocoordinate = myGeoposition.Coordinate; GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate); // Make my current location the center of the Map. this.mapWithMyLocation.Center = myGeoCoordinate; this.mapWithMyLocation.ZoomLevel = 13; // Create a small circle to mark the current location. Ellipse myCircle = new Ellipse(); myCircle.Fill = new SolidColorBrush(Colors.Red); myCircle.Height = 20; myCircle.Width = 20; myCircle.Opacity = 50; // Create a MapOverlay to contain the circle. MapOverlay myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = myCircle; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = myGeoCoordinate; // Create a MapLayer to contain the MapOverlay. MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); // Add the MapLayer to the Map. mapWithMyLocation.Layers.Add(myLocationLayer); txTop.Text = ("My Location - Lat " + myGeoCoordinate.Latitude.ToString("0.0000") + " Lon " + myGeoCoordinate.Longitude.ToString("0.0000")); }
private async Task AddCurrentLocationToMap() { var myGeolocator = new Geolocator(); var myGeoposition = await myGeolocator.GetGeopositionAsync(); var myGeocoordinate = myGeoposition.Coordinate; var myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate); var myCircle = new Ellipse(); myCircle.Fill = new SolidColorBrush(System.Windows.Media.Colors.Blue); myCircle.Height = 20; myCircle.Width = 20; myCircle.Opacity = 50; var myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = myCircle; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = myGeoCoordinate; // Create a MapLayer to contain the MapOverlay. var myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); _nativeMap.Layers.Add(myLocationLayer); }
private async void ShowMyLocationOnTheMap() { Geolocator myGeolocator = new Geolocator(); Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync(); Geocoordinate myGeocoordinate = myGeoposition.Coordinate; GeoCoordinate myGeoCoordinate = CoordinateConverterRed.ConvertGeocoordinateRed(myGeocoordinate); this.map.Center = myGeoCoordinate; this.map.ZoomLevel = 17; Ellipse myCircle = new Ellipse(); myCircle.Fill = new SolidColorBrush(Colors.Red); myCircle.Height = 20; myCircle.Width = 20; myCircle.Opacity = 50; MapOverlay myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = myCircle; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = myGeoCoordinate; MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); map.Layers.Add(myLocationLayer); }
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); }
void App_PositionUpdated(object sender, EventArgs e) { Dispatcher.BeginInvoke(() => { ForeLocationCount++; if(oneMarker == null){ oneMarker = new MapOverlay(); MapLayer oneMarkerLayer = new MapLayer(); Ellipse Circhegraphic = new Ellipse(); Circhegraphic.Fill = new SolidColorBrush(Colors.Yellow); Circhegraphic.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red); Circhegraphic.StrokeThickness = 10; Circhegraphic.Opacity = 0.8; Circhegraphic.Height = 30; Circhegraphic.Width = 30; oneMarker.Content = Circhegraphic; oneMarker.PositionOrigin = new Point(0.5, 0.5); oneMarkerLayer.Add(oneMarker); map1.Layers.Add(oneMarkerLayer); } oneMarker.GeoCoordinate = App.lastLocation; if (!App.RunningInBackground) { map1.Center = oneMarker.GeoCoordinate; } statusBox.Text = "Count :" + ForeLocationCount + "/"+ App.GottenLocationsCunt + ", sess: " + App.RunningInBackgroundCunt; }); }
public static MapOverlay DrawPushpin(MapLayer pushpinMapLayer, GeoCoordinate coord, bool isCurrentUserLocation, bool isDestination = false) { //Creating a Grid element. Grid MyGrid = new Grid(); MyGrid.RowDefinitions.Add(new RowDefinition()); MyGrid.RowDefinitions.Add(new RowDefinition()); MyGrid.Background = new SolidColorBrush(Colors.Transparent); Image img = new Image(); img.Source = new BitmapImage(new Uri(isDestination ? Constants.DestinationPin : (isCurrentUserLocation ? Constants.TrackPinEndImage : Constants.TrackPinImage), UriKind.Relative)); img.Margin = new Thickness(-15, -45, 0, 0); MyGrid.Children.Add(img); //Creating a MapOverlay and adding the Pushpin to it. MapOverlay MyOverlay = new MapOverlay(); MyOverlay.Content = MyGrid; MyOverlay.GeoCoordinate = coord; MyOverlay.PositionOrigin = new Point(0, 0.5); //Add the MapOverlay containing the pushpin to the MapLayer pushpinMapLayer.Add(MyOverlay); return(MyOverlay); }
private void AddResultToMap(GeoCoordinate location) { if (markerLayer != null) { map1.Layers.Remove(markerLayer); markerLayer = null; } markerLayer = new MapLayer(); map1.Layers.Add(markerLayer); oneMarker = new MapOverlay(); oneMarker.GeoCoordinate = location; Ellipse Circhegraphic = new Ellipse(); Circhegraphic.Fill = new SolidColorBrush(Colors.Yellow); Circhegraphic.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red); Circhegraphic.StrokeThickness = 30; Circhegraphic.Opacity = 0.8; Circhegraphic.Height = 80; Circhegraphic.Width = 80; oneMarker.Content = Circhegraphic; oneMarker.PositionOrigin = new Point(0.5, 0.5); Circhegraphic.MouseLeftButtonDown += textt_MouseLeftButtonDown; markerLayer.Add(oneMarker); map1.Center = oneMarker.GeoCoordinate; }
private async void ShowMyLocationOnTheMap() { Geolocator myGeolocator = new Geolocator(); Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync(); Geocoordinate myGeocoordinate = myGeoposition.Coordinate; GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate); // Make my current location the center of the Map. this.mapWithMyLocation.Center = myGeoCoordinate; this.mapWithMyLocation.ZoomLevel = 13; // Create a small circle to mark the current location. BitmapImage bmi = new BitmapImage(new Uri("/Assets/pushpinRood.png", UriKind.Relative)); Image img = new Image(); img.Source = bmi; // Create a MapOverlay to contain the circle. MapOverlay myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = img; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = myGeoCoordinate; // Create a MapLayer to contain the MapOverlay. MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); // Add the MapLayer to the Map. mapWithMyLocation.Layers.Add(myLocationLayer); }
/*For see you location on the map*/ private async void ShowMyLocationOnTheMap() { // Get my current location. Geolocator myGeolocator = new Geolocator(); Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync(); Geocoordinate myGeocoordinate = myGeoposition.Coordinate; GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate); // Make my current location the center of the Map. //MessageBox.Show("Latitude" + myGeoCoordinate.Latitude+ "Longitud: " + myGeoCoordinate.Longitude + "Altitud:"+myGeoCoordinate.Altitude); place = myGeocoordinate.ToGeoCoordinate().ToString(); this.mapWithMyLocation.Center = myGeoCoordinate; this.mapWithMyLocation.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; // Create a MapOverlay to contain the circle. MapOverlay myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = myCircle; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = myGeoCoordinate; // Create a MapLayer to contain the MapOverlay. MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); // Add the MapLayer to the Map. mapWithMyLocation.Layers.Add(myLocationLayer); }
private void AddPoint(Map controlMap, GeoCoordinate geo) { // With the new Map control: // Map -> MapLayer -> MapOverlay -> UIElements // - Add a MapLayer to the Map // - Add an MapOverlay to that layer // - We can add a single UIElement to that MapOverlay.Content MapLayer ml = new MapLayer(); MapOverlay mo = new MapOverlay(); // Add an Ellipse UI Ellipse r = new Ellipse(); r.Fill = new SolidColorBrush(Color.FromArgb(255, 240, 5, 5)); // the item is placed on the map at the top left corner so // in order to center it, we change the margin to a negative // margin equal to half the width and height r.Width = r.Height = 12; r.Margin = new Thickness(-6, -6, 0, 0); // Add the Ellipse to the Content mo.Content = r; // Set the GeoCoordinate of that content mo.GeoCoordinate = geo; // Add the MapOverlay to the MapLayer ml.Add(mo); // Add the MapLayer to the Map controlMap.Layers.Add(ml); }
private async Task <GeoCoordinate> ShowMyCurrentLocationOnTheMap() { // Get my current location. Geolocator myGeolocator = new Geolocator(); Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync(); myGeocoordinate = myGeoposition.Coordinate; wayPoints.Add(new GeoCoordinate(myGeocoordinate.Latitude, myGeocoordinate.Longitude)); //GeoCoordinate myxGeocoordinate = new GeoCoordinate(47.6785619, -122.1311156); myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate); // Make my current location the center of the Map. this.mapPostItinerary.Center = myGeoCoordinate; this.mapPostItinerary.ZoomLevel = 16; // Create a MapOverlay to contain the circle. myCurentLocationOverlay = MarkerDraw.DrawMapMarker(myGeoCoordinate); // Create a MapLayer to contain the MapOverlay. myLocationLayer = new MapLayer(); myLocationLayer.Add(myCurentLocationOverlay); // Add the MapLayer to the Map. mapPostItinerary.Layers.Add(myLocationLayer); return(myGeoCoordinate); }
private void AddPinOnMap() { geo1 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[0].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[0].longitude)); geo2 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[ObjRootObjectJourney.data.latlong.Count - 1].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[ObjRootObjectJourney.data.latlong.Count - 1].longitude)); Image pinIMG = new Image(); pinIMG.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Images/map/pin_green.png", UriKind.Relative)); pinIMG.Width = 50; pinIMG.Height = 50; MapOverlay myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = pinIMG; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = geo1; MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); mapJourney.Layers.Add(myLocationLayer); myLocationLayer = null; myLocationOverlay = null; pinIMG = null; pinIMG = new Image(); pinIMG.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Images/map/pin_red.png", UriKind.Relative)); pinIMG.Width = 50; pinIMG.Height = 50; myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = pinIMG; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = geo2; myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); mapJourney.Layers.Add(myLocationLayer); myLocationLayer = null; myLocationOverlay = null; pinIMG = null; mapJourney.ZoomLevel = ZoomLevel; mapJourney.Center = geo2; }
private void Websocket_MessageReceived(object sender, MessageReceivedEventArgs e) { try { var json = e.Message; TreinenWebsocketResponse result = JsonConvert.DeserializeObject <TreinenWebsocketResponse>(json); if (result.Treinen.Any()) { Deployment.Current.Dispatcher.BeginInvoke(() => { treinenLayer.Clear(); //Show treinen on map foreach (var trein in result.Treinen) { MapOverlay overlay = new MapOverlay(); overlay.Content = new TreinMapControl(trein); overlay.GeoCoordinate = new GeoCoordinate(trein.Lat, trein.Lng); treinenLayer.Add(overlay); } }); } } catch (Exception ex) { } }
private async void InitApartments() { var apartments = await App.MobileService.GetTable <Apartment>().Where(a => a.Published == true).ToListAsync(); listApartments.ItemsSource = apartments; mapApartments.Layers.Clear(); MapLayer layer = new MapLayer(); foreach (Apartment apartment in apartments) { MapOverlay overlay = new MapOverlay(); overlay.GeoCoordinate = new GeoCoordinate(apartment.Latitude, apartment.Longitude); overlay.PositionOrigin = new Point(0, 0); Grid grid = new Grid { Height = 40, Width = 25, Background = new SolidColorBrush(Colors.Red) }; TextBlock text = new TextBlock { Text = apartment.Bedrooms.ToString(), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; grid.Children.Add(text); overlay.Content = grid; grid.Tap += (s, e) => { MessageBox.Show( "Address: " + apartment.Address + Environment.NewLine + apartment.Bedrooms + " bedrooms", "Apartment", MessageBoxButton.OK); mapApartments.SetView(overlay.GeoCoordinate, 15, MapAnimationKind.Parabolic); }; layer.Add(overlay); } mapApartments.Layers.Add(layer); }
private void AddResultToMap(GeoCoordinate origin, GeoCoordinate destination) { if (markerLayer != null) { map1.Layers.Remove(markerLayer); markerLayer = null; } OriginMarker = MakeDotMarker(origin, false); DestinationMarker = MakeDotMarker(destination, true); markerLayer = new MapLayer(); map1.Layers.Add(markerLayer); markerLayer.Add(OriginMarker); markerLayer.Add(DestinationMarker); }
private async void InitApartments() { var apartments = await App.MobileService.GetTable<Apartment>().Where(a => a.Published == true).ToListAsync(); listApartments.ItemsSource = apartments; mapApartments.Layers.Clear(); MapLayer layer = new MapLayer(); foreach (Apartment apartment in apartments) { MapOverlay overlay = new MapOverlay(); overlay.GeoCoordinate = new GeoCoordinate(apartment.Latitude, apartment.Longitude); overlay.PositionOrigin = new Point(0, 0); Grid grid = new Grid { Height = 40, Width = 25, Background = new SolidColorBrush(Colors.Red) }; TextBlock text = new TextBlock { Text = apartment.Bedrooms.ToString(), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; grid.Children.Add(text); overlay.Content = grid; grid.Tap += (s, e) => { MessageBox.Show( "Address: " + apartment.Address + Environment.NewLine + apartment.Bedrooms + " bedrooms", "Apartment", MessageBoxButton.OK); mapApartments.SetView(overlay.GeoCoordinate, 15, MapAnimationKind.Parabolic); }; layer.Add(overlay); } mapApartments.Layers.Add(layer); }
private void DisplayData(MapLayer layer) { foreach (Cat cat in catCollection) { foreach (Place place in cat.Places) { MapPolyline newPolyline = new MapPolyline(); newPolyline.StrokeColor = Colors.Magenta; newPolyline.StrokeThickness = 5; newPolyline.Path = new GeoCoordinateCollection(); foreach (Diamond diamond in place.Diamonds) { MapOverlay newMapOverlay = new MapOverlay(); newMapOverlay.Content = new DiamondControl(diamond); newMapOverlay.GeoCoordinate = diamond.Point; newMapOverlay.PositionOrigin = new Point(0, 0.5); layer.Add(newMapOverlay); newPolyline.Path.Add(diamond.Point); } overheadMap.Map.MapElements.Add(newPolyline); } } }
public async void ShowLocationOnMap() { Geolocator geolocator = new Geolocator(); Geoposition geoposition = await geolocator.GetGeopositionAsync(); // Get geolocation Geocoordinate geocoordinate = geoposition.Coordinate; geoCoordinate = CoordinateConverter.ConvertGeocoordinate(geocoordinate); // Convert to a maps control compatible class map.Center = geoCoordinate; // Set current location as the centre of the map map.ZoomLevel = 13; // Create blue circle shown in app Ellipse marker = new Ellipse(); marker.Fill = new SolidColorBrush(Colors.Blue); marker.Height = 20; marker.Width = 20; marker.Opacity = 50; // Overlay blue circle on map control MapOverlay mapOverlay = new MapOverlay(); mapOverlay.Content = marker; mapOverlay.PositionOrigin = new Point(0.5, 0.5); mapOverlay.GeoCoordinate = geoCoordinate; MapLayer mapLayer = new MapLayer(); mapLayer.Add(mapOverlay); map.Layers.Add(mapLayer); }
private void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { Position item = lstPositions.Items.Last() as Position; layers = new MapLayer(); image = new BitmapImage(); image.UriSource = (new Uri(Friend.Picture, UriKind.Absolute)); grid = new Grid(); grid.DataContext = item; grid.Tap += grid_Tap; textBlock = new TextBlock(); textBlock.Text = item.Counter.ToString(); textBlock.VerticalAlignment = VerticalAlignment.Bottom; textBlock.HorizontalAlignment = HorizontalAlignment.Center; brush = new ImageBrush(); brush.ImageSource = image; ellipse = new Ellipse(); ellipse.Height = 100; ellipse.Width = 100; ellipse.Fill = brush; grid.Children.Add(ellipse); grid.Children.Add(textBlock); overlay = new MapOverlay(); overlay.GeoCoordinate = new GeoCoordinate(item.Latitude, item.Longitude); overlay.Content = grid; layers.Add(overlay); myMap.Layers.Add(layers); } }
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); }); }); }
private void ShowMyLocationOnTheMap() { // Make my current location the center of the Map. this.mapWithMyLocation.Center = new GeoCoordinate(positionLatitude, positionLongitude); this.mapWithMyLocation.ZoomLevel = 12; // 绘制圆形为当前的位置 Ellipse myCircle = new Ellipse(); myCircle.Fill = new SolidColorBrush(Colors.Red); myCircle.Height = 20; myCircle.Width = 20; myCircle.Opacity = 50; // 创建一个包含圆形的MapOverlay MapOverlay myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = myCircle; myLocationOverlay.PositionOrigin = new Point(0, 0); myLocationOverlay.GeoCoordinate = new GeoCoordinate(positionLatitude, positionLongitude); // 创建一个MapLayer包含MapOverlay MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); mapWithMyLocation.Layers.Clear(); // 将MapLayer加入到地图中 mapWithMyLocation.Layers.Add(myLocationLayer); }
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { var rootObject = JsonConvert.DeserializeObject <Rootobject>(e.Result); double lat, longitude; MapPolyline line = new MapPolyline(); line.StrokeColor = Colors.Red; line.StrokeThickness = 2; double[] coord = new double[2 * rootObject.direction[0].stop.Length]; for (int i = 0; i < rootObject.direction[0].stop.Length; i++) { lat = Convert.ToDouble(rootObject.direction[0].stop[i].stop_lat); longitude = Convert.ToDouble(rootObject.direction[0].stop[i].stop_lon); line.Path.Add(new GeoCoordinate(lat, longitude)); Ellipse myCircle = new Ellipse(); myCircle.Fill = new SolidColorBrush(Colors.Red); myCircle.Height = 10; myCircle.Width = 10; myCircle.Opacity = 60; MapOverlay myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = myCircle; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = new GeoCoordinate(lat, longitude, 200); MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); map.Layers.Add(myLocationLayer); } map.MapElements.Add(line); }
private async void ShowMyLocationOnTheMap() { Geolocator myGeolocator = new Geolocator(); Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync(); Geocoordinate myGeocoordinate = myGeoposition.Coordinate; GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate); this.BettingMap.Center = myGeoCoordinate; this.BettingMap.ZoomLevel = 15; Ellipse myCircle = new Ellipse(); myCircle.Fill = new SolidColorBrush(Colors.Blue); myCircle.Height = 20; myCircle.Width = 20; myCircle.Opacity = 50; MapOverlay myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = myCircle; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = myGeoCoordinate; MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); BettingMap.Layers.Add(myLocationLayer); }
void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { RedZone newRedZone = lstRedZones.Items.Last() as RedZone; layers = new MapLayer(); image = new BitmapImage(); image.UriSource = (new Uri(newRedZone.FbUser.Picture.data.url, UriKind.Absolute)); brush = new ImageBrush(); brush.ImageSource = image; ellipse = new Ellipse(); ellipse.DataContext = newRedZone; ellipse.Height = newRedZone.Radius / 5; ellipse.Width = newRedZone.Radius / 5; ellipse.Fill = brush; ellipse.Hold += ellipse_Hold; overlay = new MapOverlay(); overlay.GeoCoordinate = new GeoCoordinate(newRedZone.Latitude, newRedZone.Longitude); overlay.Content = ellipse; layers.Add(overlay); myMap.Layers.Add(layers); } }
private void SpecialMapIcons() { MapLayer layer = new MapLayer(); List <string[]> SpecialIcons = new List <string[]>(); SpecialIcons.Add(new string[] { "meelogic.png", "52.50209", "13.44912" }); SpecialIcons.Add(new string[] { "squirrel-entertainment.png", "52.44429", "13.39212" }); for (int i = 0; i < SpecialIcons.Count; i++) { string[] Icons = SpecialIcons[i]; MapOverlay overlay = new MapOverlay() { GeoCoordinate = new GeoCoordinate(float.Parse(Icons[1], System.Globalization.CultureInfo.InvariantCulture), float.Parse(Icons[2], System.Globalization.CultureInfo.InvariantCulture)), Content = new Image { Source = new BitmapImage(new Uri("/Assets/icon/" + Icons[0], UriKind.Relative)), Width = 50, Height = 50, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center } }; layer.Add(overlay); } Map.Layers.Add(layer); }
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); }
private void CreatePushpins() { var overlay = new MapOverlay(); overlay.GeoCoordinate = new System.Device.Location.GeoCoordinate(19.433481, -99.134065); BitmapImage bmp = new BitmapImage(new Uri("/mexico.jpg", UriKind.Relative)); overlay.Content = new Image() { Source = bmp, Width = 50 }; var overlay2 = new MapOverlay(); overlay2.GeoCoordinate = new System.Device.Location.GeoCoordinate(-12.115488, -77.044122); BitmapImage bmp2 = new BitmapImage(new Uri("/peru.jpg", UriKind.Relative)); overlay2.Content = new Image() { Source = bmp2, Width=50 }; var layer = new MapLayer(); layer.Add(overlay); layer.Add(overlay2); map.Layers.Add(layer); }
// Constructor public MainPage() { InitializeComponent(); markerLayer = new MapLayer(); startMark = AddMarkersToMap("Start", new GeoCoordinate(60.2214, 24.7572)); markerLayer.Add(startMark); enddMark = AddMarkersToMap("End", new GeoCoordinate(61.4468, 23.8646)); markerLayer.Add(enddMark); map1.Layers.Add(markerLayer); geoQ = new RouteQuery(); geoQ.QueryCompleted += geoQ_QueryCompleted; Debug.WriteLine("All construction done for rutting"); }
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); }
void MainPage_Loaded(object sender, RoutedEventArgs e) { mainMap.Center = new System.Device.Location.GeoCoordinate(41.532887, -87.355024); mainMap.ZoomLevel = 17; mainMap.Pitch = 45; mainMap.LandmarksEnabled = true; InitializeGPS(); InitializePolygons(); mapLayer = new MapLayer(); mapLayer.Add(Car); mainMap.Layers.Add(mapLayer); //--Add to load routeQuery = new RouteQuery(); routeQuery.QueryCompleted += routeQuery_QueryCompleted; }
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); }
private void MarcarPosicaoNoMapa(double latitude, double longitude, Color cor) { Ellipse marcacao = new Ellipse(); marcacao.Fill = new SolidColorBrush(cor); marcacao.Height = 10; marcacao.Width = 10; MapLayer camada = new MapLayer(); MapOverlay sobrecamada = new MapOverlay(); sobrecamada.Content = marcacao; sobrecamada.GeoCoordinate = new GeoCoordinate(latitude, longitude); camada.Add(sobrecamada); Mapa.Layers.Add(camada); }
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); }
// :Helper functions // :Draw map point private void _DrawPoint(double latitude, double longitude) { Ellipse myCircle = new Ellipse(); myCircle.Fill = new SolidColorBrush(Colors.Blue); myCircle.Height = 20; myCircle.Width = 20; myCircle.Opacity = 50; MapOverlay myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = myCircle; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = new GeoCoordinate(latitude, longitude); // Create a MapLayer to contain the MapOverlay. MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); MapOfRunningRoute.Layers.Add(myLocationLayer); }
void MainPage_Loaded(object sender, RoutedEventArgs e) { MontpellierGeo = new GeoCoordinate(43.5822454960498, 3.92993819945295); MyMap.Center = new GeoCoordinate(43.5822454960498, 3.92993819945295); MyMap.ZoomLevel = 12; MyLayer = new MapLayer(); PtLayer = new MapLayer(); MyMap.Layers.Add(MyLayer); MyMap.Layers.Add(PtLayer); Dispatcher.BeginInvoke(() => { ReadFeux(); }); MyPin = new MapOverlay(); MyLayer.Add(MyPin); Grid MyContent = new Grid(); BitmapImage meBitmap = new BitmapImage(new Uri("Assets/Images/me.png", UriKind.Relative)); MyContent.Children.Add(new Image() { Source = meBitmap }); MyPin.Content = MyContent; try { if (canUseLoc()) { PosWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); PosWatcher.MovementThreshold = 20; // 20 meters PosWatcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(OnStatusChanged); PosWatcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(OnPositionChanged); PosWatcher.Start(); } } catch (Exception) { } }
public void ShowPointOnMap(double lat, double lng, Map map, int zoomLevel) { GeoCoordinate myCoordinate = new GeoCoordinate(lat, lng); map.Center = myCoordinate; map.ZoomLevel = zoomLevel; //Create icon on map Image addressIcon = new Image(); addressIcon.Source = new BitmapImage(new Uri("/Images/Icons/img_MyPositionIcon.png", UriKind.Relative)); // Create a MapOverlay to contain the circle. MapOverlay myOvelay = new MapOverlay(); myOvelay.Content = addressIcon; myOvelay.PositionOrigin = new Point(0.5, 0.5); myOvelay.GeoCoordinate = myCoordinate; //Add to Map's Layer MapLayer myMaplayer = new MapLayer(); myMaplayer.Add(myOvelay); map.Layers.Add(myMaplayer); }
private void AddResultToMap(String text, GeoCoordinate location) { if (markerLayer != null) { map1.Layers.Remove(markerLayer); markerLayer = null; } markerLayer = new MapLayer(); MapOverlay oneMarker = new MapOverlay(); oneMarker.GeoCoordinate = location; Canvas canCan = new Canvas(); Ellipse Circhegraphic = new Ellipse(); Circhegraphic.Fill = new SolidColorBrush(Colors.Brown); Circhegraphic.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green); Circhegraphic.StrokeThickness = 5; Circhegraphic.Opacity = 0.8; Circhegraphic.Height = 40; Circhegraphic.Width = 40; canCan.Children.Add(Circhegraphic); TextBlock textt = new TextBlock { Text = text }; textt.HorizontalAlignment = HorizontalAlignment.Center; Canvas.SetLeft(textt,10); Canvas.SetTop(textt, 5); Canvas.SetZIndex(textt, 5); canCan.Children.Add(textt); oneMarker.Content = canCan; oneMarker.PositionOrigin = new Point(0.5, 0.5); textt.MouseLeftButtonUp += textt_MouseLeftButtonUp; markerLayer.Add(oneMarker); map1.Layers.Add(markerLayer); }
// Constructor public MainPage() { InitializeComponent(); System.Windows.Input.Touch.FrameReported += Touch_FrameReported; MapLayer oneMarkerLayer = new MapLayer(); oneMarker = new MapOverlay(); Canvas canCan = new Canvas(); Ellipse Circhegraphic = new Ellipse(); Circhegraphic.Fill = new SolidColorBrush(Colors.Brown); Circhegraphic.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green); Circhegraphic.StrokeThickness = 5; Circhegraphic.Opacity = 0.8; Circhegraphic.Height = 40; Circhegraphic.Width = 60; canCan.Children.Add(Circhegraphic); TextBlock MarkerTxt = new TextBlock { Text = "Drag" }; MarkerTxt.HorizontalAlignment = HorizontalAlignment.Center; Canvas.SetLeft(MarkerTxt, 10); Canvas.SetTop(MarkerTxt, 5); Canvas.SetZIndex(MarkerTxt, 5); canCan.Children.Add(MarkerTxt); oneMarker.Content = canCan; oneMarker.PositionOrigin = new Point(0.5, 0.5); oneMarker.GeoCoordinate = new GeoCoordinate(60.35, 24.60); MarkerTxt.MouseLeftButtonDown += marker_MouseLeftButtonDown; oneMarkerLayer.Add(oneMarker); map1.Layers.Add(oneMarkerLayer); map1.Center = oneMarker.GeoCoordinate; }
private async void GetCoordinates() { // Get the phone's current location. Geolocator MyGeolocator = new Geolocator(); MyGeolocator.DesiredAccuracyInMeters = 5; Geoposition MyGeoPosition = null; try { MyGeoPosition = await MyGeolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10)); MyCoordinates.Add(new GeoCoordinate(MyGeoPosition.Coordinate.Latitude, MyGeoPosition.Coordinate.Longitude)); myMap.Center = new GeoCoordinate(MyGeoPosition.Coordinate.Latitude, MyGeoPosition.Coordinate.Longitude); Debug.WriteLine(MyGeoPosition.Coordinate.Latitude + " " + MyGeoPosition.Coordinate.Longitude); markerLayer = new MapLayer(); startMark = AddMarkersToMap("", MyCoordinates[0]); markerLayer.Add(startMark); myMap.Layers.Add(markerLayer); //endMark = AddMarkersToMap("", MyCoordinates[1]); //markerLayer.Add(startMark); Mygeocodequery = new GeocodeQuery(); Mygeocodequery.SearchTerm = "Hanoi, VN"; Mygeocodequery.GeoCoordinate = new GeoCoordinate(MyGeoPosition.Coordinate.Latitude, MyGeoPosition.Coordinate.Longitude); Mygeocodequery.QueryCompleted += Mygeocodequery_QueryCompleted; Mygeocodequery.QueryAsync(); } catch (UnauthorizedAccessException) { MessageBox.Show("Location is disabled in phone settings or capabilities are not checked."); } catch (Exception ex) { // Something else happened while acquiring the location. MessageBox.Show(ex.Message); } }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { // setup GPS map.ColorMode = Microsoft.Phone.Maps.Controls.MapColorMode.Light; map.CartographicMode = Microsoft.Phone.Maps.Controls.MapCartographicMode.Road; map.LandmarksEnabled = true; map.PedestrianFeaturesEnabled = true; map.ZoomLevel = 17; txtCurrentSpeed.Foreground = new SolidColorBrush(Colors.Black); overlay.Content = txtCurrentSpeed; routeQuery.TravelMode = Microsoft.Phone.Maps.Services.TravelMode.Walking; routeQuery.QueryCompleted += rq_QueryCompleted; MapLayer currentSpeedLayer = new MapLayer(); currentSpeedLayer.Add(overlay); map.Layers.Add(currentSpeedLayer); map.Layers.Add(historicalReadingsLayer); map.MapElements.Add(polyline); base.OnNavigatedTo(e); }
private void MyMap_Loaded(object sender, RoutedEventArgs e) { double lat = double.Parse(App.ViewModel.Items[index].Latitude); double lon = double.Parse(App.ViewModel.Items[index].Longitude); MyMap.Center = new GeoCoordinate(lat, lon); MyMap.ZoomLevel = 15; // Create a small circle to mark the current meetup location. Ellipse myCircle = new Ellipse(); myCircle.Fill = new SolidColorBrush(Colors.Red); myCircle.Height = 20; myCircle.Width = 20; myCircle.Opacity = 50; MapOverlay myOverlay = new MapOverlay(); myOverlay.Content = myCircle; myOverlay.PositionOrigin = new Point(0.5, 0.5); myOverlay.GeoCoordinate = MyMap.Center; MapLayer myLayer = new MapLayer(); myLayer.Add(myOverlay); MyMap.Layers.Add(myLayer); }
private async void GetCoordinates() { Geolocator MyGeolocator = new Geolocator(); MyGeolocator.DesiredAccuracyInMeters = 5; Geoposition MyGeoPosition = null; try { MyGeoPosition = await MyGeolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10)); currentGeoCoordinate = ConvertGeocoordinate(MyGeoPosition.Coordinate); myMap.Center = currentGeoCoordinate; myMap.ZoomLevel = 20; Ellipse myEllipse = new Ellipse(); myEllipse.Fill = new SolidColorBrush(Colors.Red); myEllipse.Height = 30; myEllipse.Width = 30; MapOverlay mapOverlay = new MapOverlay(); mapOverlay.Content = myEllipse; mapOverlay.PositionOrigin = new Point(0.5, 0.5); mapOverlay.GeoCoordinate = currentGeoCoordinate; MapLayer mapLayer = new MapLayer(); mapLayer.Add(mapOverlay); myMap.Layers.Add(mapLayer); } catch (UnauthorizedAccessException) { MessageBox.Show("Location is disabled in phone settings"); } catch (Exception ex) { } }
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); }); }); }