public void SetTreePins(List<Tree> trees, string name) { map.Children.Clear(); foreach (Tree tree in trees) { MapPolygon point = new MapPolygon(); point.Stroke = new SolidColorBrush(Colors.White); point.Fill = new SolidColorBrush(Colors.Green); point.Opacity = 0.7f; Location location1 = new Location() { Latitude = tree.Coordinates.X - 0.0001, Longitude = tree.Coordinates.Y - 0.00006 }; Location location2 = new Location() { Latitude = tree.Coordinates.X + 0.0001, Longitude = tree.Coordinates.Y - 0.00006 }; Location location3 = new Location() { Latitude = tree.Coordinates.X + 0.0001, Longitude = tree.Coordinates.Y + 0.00006 }; Location location4 = new Location() { Latitude = tree.Coordinates.X - 0.0001, Longitude = tree.Coordinates.Y + 0.00006 }; LocationCollection locations = new LocationCollection(); locations.Add(location1); locations.Add(location2); locations.Add(location3); locations.Add(location4); point.Locations = locations; map.Children.Add(point); /* Pushpin pin = new Pushpin(); pin.Location = new GeoCoordinate(tree.Coordinates.X, tree.Coordinates.Y); pin.Content = name; map.Children.Add(pin); * */ } NavigationService.GoBack(); }
public Favorites() { InitializeComponent(); LoadWatcher(); map1.LogoVisibility = Visibility.Collapsed; map1.CopyrightVisibility = Visibility.Collapsed; map1.Mode = new AerialMode(); map1.ZoomLevel = 5; map1.ZoomBarVisibility = System.Windows.Visibility.Visible; var settings = IsolatedStorageSettings.ApplicationSettings; if (settings.Contains("favorites")) { var location = settings["favorites"].ToString(); latitude = double.Parse(location.Substring(0, location.IndexOf(",") - 1)); longtitude = double.Parse(location.Substring(location.IndexOf(",") + 1)); var locationsList = new LocationCollection(); //locationsList.Add(new GeoCoordinate(56.5845698,40.5489514)); //locationsList.Add(new GeoCoordinate(60.4885213, 80.785426)); locationsList.Add(new GeoCoordinate(latitude,longtitude)); locationsList.Add(new GeoCoordinate(latitude+0.85412, longtitude+0.12564)); MapPolyline polyline = new MapPolyline(); polyline.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black); polyline.StrokeThickness = 5; polyline.Opacity = 0.8; polyline.Locations = locationsList; //Pushpin pin = new Pushpin(); //MessageBox.Show(location.Substring(0, location.IndexOf(",") - 1) + " \n " + location.Substring(location.IndexOf(",") + 1)); ////---set the location for the pushpin--- //pin.Location = new GeoCoordinate(double.Parse(location.Substring(0, location.IndexOf(",") - 1)), double.Parse(location.Substring(location.IndexOf(",") + 1))); //pin.Name = "tmp"; ////---add the pushpin to the map--- //pin.Content = new Ellipse() //{ // //Fill = image, // StrokeThickness = 10, // Height = 100, // Width = 100 //}; //pin.MouseLeftButtonUp += new MouseButtonEventHandler(Pushpin_MouseLeftButtonUp); //---add the pushpin to the map--- map1.Children.Add(polyline); MessageBox.Show(location.ToString()); } // settings["myemail"] = "*****@*****.**"; }
public Edge(ListeningStation from, ListeningStation to, double value) { ID = from.ID + " - " + to.ID; Name = from.Name + " - " + to.Name; LocationCollection vertices = new LocationCollection(); vertices.Add(from.Location); vertices.Add(to.Location); Vertices = vertices; Value = value; }
private void BuildPolyline() { LocationCollection points = new LocationCollection(); points.Add(new Location(40, -100)); points.Add(new Location(41, -101)); points.Add(new Location(40, -102)); points.Add(new Location(43, -103)); points.Add(new Location(45, -97)); MapPolyline polyline = new MapPolyline(); polyline.Points = points; this.polylineLayer.Items.Add(polyline); this.BuildPoints(polyline); }
public static TravelData ParseXMLToRoad(XmlDocument data) { XmlNamespaceManager nsmgr = new XmlNamespaceManager(data.NameTable); nsmgr.AddNamespace("rest", "http://schemas.microsoft.com/search/local/ws/rest/v1"); XmlNodeList roadElements = data.SelectNodes("//rest:Line", nsmgr); if (roadElements.Count == 0) { MessageBox.Show("No road found :(", "Highway to hell", MessageBoxButton.OK, MessageBoxImage.Error); return null; } else { LocationCollection locations = new LocationCollection(); XmlNodeList points = roadElements[0].SelectNodes(".//rest:Point", nsmgr); foreach (XmlNode point in points) { string latitude = point.SelectSingleNode(".//rest:Latitude", nsmgr).InnerText; string longitude = point.SelectSingleNode(".//rest:Longitude", nsmgr).InnerText; locations.Add(XML.SetGeographicInfo(latitude, longitude)); } TravelData travelData = new TravelData(); travelData.StringDistance = data.SelectSingleNode(".//rest:TravelDistance", nsmgr).InnerText; travelData.StringTravelTime = data.SelectSingleNode(".//rest:TravelDuration", nsmgr).InnerText; travelData.Locations = locations; return travelData; } }
public override void AddPinsToLayer() { foreach (PointOfInterest poi in Points) { MapPolygon polygon = new MapPolygon(); polygon.Fill = new SolidColorBrush(_Colors[colorIndex++ % _Colors.Length]); polygon.Opacity = 0.25; LocationCollection locCol = new LocationCollection(); foreach( string line in poi.Coordinates.Split('\n') ) { if (!string.IsNullOrEmpty(line)) { string[] vals = line.Split(','); locCol.Add( new Location() { Latitude = double.Parse(vals[1]), Longitude = double.Parse(vals[0]), Altitude = 0 }); } } polygon.Locations = locCol; MapLayer.Children.Add(polygon); } }
public RouteModel(IEnumerable<GeoCoordinate> locations) { _locations = new LocationCollection(); foreach (var location in locations) { _locations.Add(location); } }
public RouteModel(IEnumerable <GeoCoordinate> locations) { _locations = new LocationCollection(); foreach (var location in locations) { _locations.Add(location); } }
/// <summary> /// Initializes a new instance of this type. /// </summary> /// <param name="locations">A collection of locations.</param> public RouteModel(ICollection<Location> locations) { _locations = new LocationCollection(); foreach (Location location in locations) { _locations.Add(location); } }
/// <summary> /// Initializes a new instance of this type. /// </summary> /// <param name="locations">A collection of locations.</param> public RouteModel(ICollection <Location> locations) { _locations = new LocationCollection(); foreach (Location location in locations) { _locations.Add(location); } }
private void BtnCalc_Click(object sender, RoutedEventArgs e) { string myFile = @"c:\ProgramData\Adobe\ARM\Reader_15.008.20082\Visual Studio\C#\Bing\Gpx\1_בדצמ׳_2020_22_02_01.gpx"; ds.ReadXml(myFile); myTbl = ds.Tables["trkpt"]; var locs = new LocationCollection(); for (int i = 0; i < myTbl.Rows.Count; i = i + 10) { locs.Add(new Microsoft.Maps.MapControl.WPF.Location(Convert.ToDouble(myTbl.Rows[i]["lat"]), Convert.ToDouble(myTbl.Rows[i]["lon"]))); } var routeLine = new MapPolyline() { Locations = locs, Stroke = new SolidColorBrush(Colors.Blue), StrokeThickness = 5 }; mMap.Children.Add(routeLine); Microsoft.Maps.MapControl.WPF.Location start = new Microsoft.Maps.MapControl.WPF.Location(locs[locs.Count - 1].Latitude, locs[locs.Count - 1].Longitude); Microsoft.Maps.MapControl.WPF.Location end = new Microsoft.Maps.MapControl.WPF.Location(locs[0].Latitude, locs[0].Longitude); Pushpin pushpinStart = new Pushpin(); pushpinStart.Location = start; Pushpin pushpinEnd = new Pushpin(); pushpinEnd.Location = end; //mMap.Children.Add(pushpinStart); mMap.Children.Add(pushpinEnd); Image image = new Image(); BitmapImage bitmap = new BitmapImage(new Uri("pack://application:,,,/Bing;component/Resources/pushRed2.png")); image.Source = bitmap; image.Width = 50; image.Height = 50; MapLayer layer = new MapLayer(); PositionOrigin position = PositionOrigin.BottomCenter; layer.AddChild(image, start, position); mMap.Children.Add(layer); mMap.SetView(start, 10); mMap.Center = start; }
public Population() { InitializeComponent(); DatabaseOperation.Connect(); SqlDataReader readerYear = DatabaseOperation.SelectQuery("SELECT Year FROM Population"); while (readerYear.Read()) { comboboxyear.Items.Add(readerYear.GetString(0)); //zoneLocationFromDB = readerYear.GetString(2); } readerYear.Close(); SqlDataReader reader = DatabaseOperation.SelectQuery("SELECT * FROM Zone WHERE ZoneId='Zone1'"); while (reader.Read()) { zoneLocationFromDB = reader.GetString(2); } reader.Close(); DatabaseOperation.Disconnect(); //zone1 area zone1 = new LocationCollection(); string[] zoneLoc = zoneLocationFromDB.Split('|'); for (int i = 0; i < 5; i++) { string[] collection = zoneLoc[i].Split(','); Location l = new Location(Convert.ToDouble(collection[0]), Convert.ToDouble(collection[1])); zone1.Add(l); if (i == 0) { ll = l; } } zone1.Add(ll); NewMap = new MyMap(myMap, MapKey); myMap.Center = new Location(21.182782, 72.808912); myMap.ZoomLevel = 17; myMap.Focus(); }
public static LocationCollection ToLocationCollection (this IList<BasicGeoposition>PointList) { var locations = new LocationCollection(); foreach (var p in PointList) { locations.Add(p.ToLocation()); } return locations; }
public static LocationCollection CoordinatesToLocationCollection(ICoordinate[] coordinates) { var locations = new LocationCollection(); foreach (var coordinate in coordinates) { locations.Add(ConvertBack(coordinate)); } return locations; }
/// <summary> /// double click and teleport. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Map_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var loc = map.ViewportPointToLocation(e.GetPosition(map)); route.Add(loc); DrawWayPoints(); e.Handled = true; return; }
public void LoadBounties() { // clear the bounties foreach (MapLayer map in m_MapBounties.Values) { map.Children.Clear(); } foreach (GuildBounty bounty in GuildBountyDefinitions.BOUNTIES) { int mid = bounty.MapId; if (!m_MapLayers.ContainsKey(mid)) { m_MapLayers.Add(mid, new MapLayer()); } BountyMapLayer b = new BountyMapLayer(bounty.Name); if (!m_MapBounties.ContainsKey(mid)) { m_MapBounties.Add(mid, new MapLayer()); // map bounties default to hidden m_MapBounties[mid].Visibility = Visibility.Collapsed; // we insert instead of add so events always show up under other pushpins m_MapLayers[mid].Children.Insert(0, m_MapBounties[mid]); } if (bounty.Spawns != null) { foreach (List <double> p in bounty.Spawns) { b.AddSpawningPoint(ArenaNetMap.Unproject(new Point(p[0], p[1]), ArenaNetMap.MaxZoomLevel)); } } if (bounty.Paths != null) { int i = 0; foreach (GuildBountyPath path in bounty.Paths) { LocationCollection locs = new LocationCollection(); foreach (List <double> p in path.Points) { locs.Add(ArenaNetMap.Unproject(new Point(p[0], p[1]), ArenaNetMap.MaxZoomLevel)); } b.AddPath(locs, BOUNTY_PATH_BRUSHES[i], path.Direction); i = (i + 1) % BOUNTY_PATH_BRUSHES.Length; } } m_MapBounties[mid].Children.Add(b); } }
public static LocationCollection CoordinatesToLocationCollection(ICoordinate[] coordinates) { var locations = new LocationCollection(); foreach (var coordinate in coordinates) { locations.Add(ConvertBack(coordinate)); } return(locations); }
private void DrawRegionFromPins() { LocationCollection locations = new LocationCollection(); foreach (DragPin p in Dragpins) { locations.Add(p.Location); } DrawRegion(locations); }
public LocationRect ComputeLocationBounds(IEnumerable <Location> locations) { LocationCollection collection = new LocationCollection(); foreach (var loc in locations) { collection.Add(loc); } return(new LocationRect(collection)); }
public static LocationCollection MapPointsToLocations(IEnumerable<MapPoint> mapPoints) { var locations = new LocationCollection(); foreach (var mapPoint in mapPoints) { locations.Add(new Location(mapPoint.Lat, mapPoint.Lng)); } return locations; }
/// <summary> /// Add Ellipse to indicate point location /// </summary> /// <param name="loc">Location lat,lon</param> /// <param name="fields">string of attributes for tooltip</param> /// <param name="layer">MapLeyer to add to</param> /// <summary> /// Render simple linestring features /// </summary> /// <param name="shapegeo">simple point feature</param> /// <param name="label">attributes for tooltip</param> /// <param name="currentLayer">MapLayer to add to</param> private LocationCollection GetLine(MapLine shapegeo) { LocationCollection p = new LocationCollection(); foreach (LatLong pt in shapegeo.Locations) { p.Add(new Location(pt.Latitude, pt.Longitude)); } return(p); }
/// <summary> /// Converts a value. /// </summary> /// <param name="value">The value produced by the binding source.</param> /// <param name="targetType">The type of the binding target property.</param> /// <param name="parameter">The converter parameter to use.</param> /// <param name="culture">The culture to use in the converter.</param> /// <returns> /// A converted value. If the method returns null, the valid null value is used. /// </returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { List<Coordinate> coordinates = value as List<Coordinate>; LocationCollection collection = new LocationCollection(); foreach (Coordinate coord in coordinates) { collection.Add(new GeoCoordinate(coord.Latitude,coord.Longitude)); } return collection; }
public MainWindowViewModel() { Locations = new LocationCollection(); TestContent = "Wahaha"; Locations.Add(new Location(0, 0)); Locations.Add(new Location(101, 110)); Locations.Add(new Location(390, 450)); Person person = new Person(); person.Name = "Steve Ballmer"; person.Image = new BitmapImage(new Uri("image/photo.png", UriKind.Relative)); Location loc = new Location(500, 583); loc.PersonInfo = person; Locations.Add(loc); string dataPath = Environment.CurrentDirectory; CallRecordData = new XmlDataProvider(); CallRecordData.Source = new Uri(dataPath + "/data/2013-03-16.xml"); CallRecordData.InitialLoad(); }
/// <summary> /// Logika routingu. /// Skorzystałem z BingMapsRESTToolkit /// </summary> /// <param name="fwp">FirstWaypoint - Lokalizacja jednego pina - tego ze zwierzakiem</param> /// <param name="swp">SecondWaypoint - Lokalizacja drugiego pina - destynacji</param> /// <param name="key">Klucz do map bing</param> /// <param name="map">Referencja do mapy, aby dodać do niej drogę</param> /// <returns></returns> public static async Task GetRoute(Microsoft.Maps.MapControl.WPF.Location fwp, Microsoft.Maps.MapControl.WPF.Location swp, String key, Map map) { var request = new RouteRequest() { Waypoints = new List <SimpleWaypoint>() { new SimpleWaypoint(fwp.Latitude, fwp.Longitude), new SimpleWaypoint(swp.Latitude, swp.Longitude) }, BingMapsKey = key, RouteOptions = new RouteOptions() { TravelMode = TravelModeType.Driving, Optimize = RouteOptimizationType.Time, RouteAttributes = new List <RouteAttributeType>() { RouteAttributeType.RoutePath } } }; var response = await request.Execute(); if (response != null && response.ResourceSets != null && response.ResourceSets.Length > 0 && response.ResourceSets[0].Resources != null && response.ResourceSets[0].Resources.Length > 0) { var result = response.ResourceSets[0].Resources[0] as Route; double[][] routePath = result.RoutePath.Line.Coordinates; LocationCollection locs = new LocationCollection(); for (int i = 0; i < routePath.Length; ++i) { if (routePath[i].Length >= 2) { locs.Add(new Microsoft.Maps.MapControl.WPF.Location(routePath[i][0], routePath[i][1])); } } MainWindow.Waypoints = new LocationCollection(); MainWindow.Waypoints = locs; MainWindow.ReceivedRoute = new MapPolyline() { Locations = locs, Stroke = new SolidColorBrush(Colors.Black), StrokeThickness = 2 }; map.Children.Add(MainWindow.ReceivedRoute); } }
public static LocationCollection ToLocationCollection(this IList <BasicGeoposition> pointList) { var locs = new LocationCollection(); foreach (var p in pointList) { locs.Add(p.ToLocation()); } return(locs); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is IEnumerable<Location>) { var collection = new LocationCollection(); foreach (var l in ((IEnumerable<Location>)value)) collection.Add(l); return collection; } return null; }
private LocationCollection PointDArrayToLocationCollection(PointD[] points) { LocationCollection locations = new LocationCollection(); int numPoints = points.Length; for (int i = 0; i < numPoints; i++) { locations.Add(new Location(points[i].Y, points[i].X)); } return(locations); }
/// <summary> /// Converts a value. /// </summary> /// <param name="value">The value produced by the binding source.</param> /// <param name="targetType">The type of the binding target property.</param> /// <param name="parameter">The converter parameter to use.</param> /// <param name="culture">The culture to use in the converter.</param> /// <returns> /// A converted value. If the method returns null, the valid null value is used. /// </returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { List <Coordinate> coordinates = value as List <Coordinate>; LocationCollection collection = new LocationCollection(); foreach (Coordinate coord in coordinates) { collection.Add(new GeoCoordinate(coord.Latitude, coord.Longitude)); } return(collection); }
/// <summary> /// Converts a CoordinateCollection into a Bing Maps LocationCollection. /// </summary> /// <param name="coordinates">CoordinateCollection to convert.</param> /// <returns>LocationCollection of the converted CoordinateCollection.</returns> public static LocationCollection ToBMGeometry(this CoordinateCollection coordinates) { var locs = new LocationCollection(); foreach (var c in coordinates) { locs.Add(new Location(c.Latitude, c.Longitude)); } return(locs); }
/// <summary> /// Create a new MapPolyline /// </summary> /// <param name="startPoint">starting Location</param> private void CreateNewPolyline(Location startPoint) { polyline = new MapPolyline(); polyline.Stroke = new SolidColorBrush(Colors.Red); polyline.StrokeThickness = 2; var lc = new LocationCollection(); lc.Add(startPoint); polyline.Locations = lc; VEMap.Children.Add(polyline); }
private async void SetUpMap() { LocationCollection locations = new LocationCollection(); foreach (var station in this.Stations) { Location location = new Location() { Latitude = station.Latitude, Longitude = station.Longitude }; locations.Add(location); DrawPin.SetStationPin(location, this.Map, station); } try { Data.LocationProvider.Location locator = new Data.LocationProvider.Location(); Point currentLocation = await locator.CurrentPosition; if (currentLocation != null) { Location myLocation = new Location(currentLocation.Latitude, currentLocation.Longitude); string myCity = await GetCityByLocation(myLocation); DrawPin.SetMyLocationPin(myLocation, this.Map); if (myCity.Contains("London")) { locations.Add(myLocation); } LocationRect mapRectangle = new LocationRect(locations); this.Map.SetView(mapRectangle); } else { Notification.ShowMessage("Sorry! Couldn't get your position! No relevant information can be provided!"); } } catch (Exception) { Notification.ShowMessage("Sorry! Could not load data! Try to reconnect to Internet and then press Refresh!"); } }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { ////if (IsInDesignMode) ////{ //// // Code runs in Blend --> create design time data. ////} ////else ////{ //// // Code runs "for real" ////} riverSpree.Add(new Location(52.529198, 13.274099)); riverSpree.Add(new Location(52.531835, 13.29234)); riverSpree.Add(new Location(52.522116, 13.298541)); riverSpree.Add(new Location(52.520569, 13.317349)); riverSpree.Add(new Location(52.524877, 13.322434)); riverSpree.Add(new Location(52.522788, 13.329)); riverSpree.Add(new Location(52.517056, 13.332075)); riverSpree.Add(new Location(52.522514, 13.340743)); riverSpree.Add(new Location(52.517239, 13.356665)); riverSpree.Add(new Location(52.523063, 13.372158)); riverSpree.Add(new Location(52.519198, 13.379453)); riverSpree.Add(new Location(52.522462, 13.392328)); riverSpree.Add(new Location(52.520921, 13.399703)); riverSpree.Add(new Location(52.515333, 13.406054)); riverSpree.Add(new Location(52.514863, 13.416354)); riverSpree.Add(new Location(52.506034, 13.435923)); riverSpree.Add(new Location(52.496473, 13.461587)); riverSpree.Add(new Location(52.487641, 13.483216)); riverSpree.Add(new Location(52.488739, 13.491456)); riverSpree.Add(new Location(52.464011, 13.503386)); satellite.Add(new Location(52.590117, 13.39915)); satellite.Add(new Location(52.437385, 13.553989)); if (!IsInDesignMode) { FindMaximumCommand = new RelayCommand(FindMaximum); StopOptimizerCommand = new RelayCommand(StopOptimizer); } }
private void GeoRangeToPolygon(SqlGeography geoRange, LocationCollection polygon) { int numPoints = geoRange.STNumPoints().Value; polygon.Clear(); for (int i = 1; i <= numPoints; i++) { SqlGeography point = geoRange.STPointN(i); polygon.Add(new Location(point.Lat.Value, point.Long.Value)); } }
public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture) { var pathPoints = (Point[])value; var locations = new LocationCollection(); foreach (var pathPoint in pathPoints) { locations.Add(pathPoint.AsGeoCoordinate()); } return locations; }
private void DrawRouteOnBingMap(List <Node> route, Color color, bool Dijkstry) { MapPolyline polygon = new MapPolyline(); polygon.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Transparent); polygon.Stroke = new System.Windows.Media.SolidColorBrush(color); polygon.StrokeThickness = 5; polygon.Opacity = 0.7; LocationCollection path = new LocationCollection(); foreach (var node in route) { path.Add(new Location(node.Y, node.X)); } if (!Dijkstry) { path.Add(path.ElementAt(0)); } polygon.Locations = path; bingMap.Children.Add(polygon); }
private void OnFlightRouteReady(object sender, FlightRouteReadyEventArgs args) { if (flightRouteUIElementsMap.ContainsKey(args.FlightPlanName)) { // we already have a collection describing this particular route. // don't need to add a copy. return; } // polyline + markers List <UIElement> flightUIElem = new List <UIElement>(args.FlightPlan.waypoints + 1); MapPolyline polyline = new MapPolyline(); Color color = RouteColors[ColorIndex++ % RouteColors.Length]; polyline.Stroke = new SolidColorBrush(color); polyline.StrokeThickness = 5; polyline.Opacity = 0.7; LocationCollection collection = new LocationCollection(); for (int i = 0; i < args.FlightPlan.waypoints; i++) { // fill polyline NavigationNode currentNode = args.FlightPlan.route.nodes[i]; collection.Add(new Location(currentNode.lat, currentNode.lon)); // add marker Pushpin pin = new Pushpin(); pin.Location = new Location(currentNode.lat, currentNode.lon); pin.ToolTip = args.FlightPlan.notes; pin.Content = currentNode.type; pin.Background = GetColorFromNavigationNodeType(currentNode.type); BingMap.Children.Add(pin); flightUIElem.Add(pin); } polyline.Locations = collection; BingMap.Children.Add(polyline); flightUIElem.Add(polyline); flightRouteUIElementsMap.Add(args.FlightPlanName, flightUIElem); FlightRouteDrawEventArgs e = new FlightRouteDrawEventArgs(); e.FlightRouteData = args; e.RouteColor = color; NewFlightRouteDrawDelegate?.Invoke(this, e); }
public Locat() { InitializeComponent(); //Adding pushpin Pushpin pushpin = new Pushpin(); Location location = new Location(); location.Latitude = 13.0205; location.Longitude = 77.5877; pushpin.Location = location; pushpin.Background = new SolidColorBrush(Colors.Orange); pushpin.Content = "M.S Ramaiah Memorial Hospital"; pushpin.FontSize = 30; pushpin.Opacity = .9; //Adding polygon MapPolygon mapPolygon = new MapPolygon(); mapPolygon.Fill = new SolidColorBrush(Colors.Purple); mapPolygon.Stroke = new SolidColorBrush(Colors.White); mapPolygon.Opacity = .7; LocationCollection locations = new LocationCollection(); Location location1 = new Location(); location1.Latitude = 13.0205; location1.Longitude = 77.5877; Location location2 = new Location(); location1.Latitude = 20.0205; location1.Longitude = 77.5877; locations.Add(location); locations.Add(location1); locations.Add(location2); mapPolygon.Locations = locations; //MapControl.Children.Add(pushpin); //MapControl.Children.Add(mapPolygon); }
private async void UpdateRoute(Pushpin StartPin, Pushpin EndPin) { RouteLayer.Children.Clear(); var startCoord = LocationToCoordinate(StartPin.Location); var endCoord = LocationToCoordinate(EndPin.Location); var response = await BingMapsRESTToolkit.ServiceManager.GetResponseAsync(new BingMapsRESTToolkit.RouteRequest() { Waypoints = new List <BingMapsRESTToolkit.SimpleWaypoint>() { new BingMapsRESTToolkit.SimpleWaypoint(startCoord), new BingMapsRESTToolkit.SimpleWaypoint(endCoord) }, BingMapsKey = SESSION_KEY, RouteOptions = new BingMapsRESTToolkit.RouteOptions() { RouteAttributes = new List <BingMapsRESTToolkit.RouteAttributeType> { BingMapsRESTToolkit.RouteAttributeType.RoutePath } } }); if (response != null && response.ResourceSets != null && response.ResourceSets.Length > 0 && response.ResourceSets[0].Resources != null && response.ResourceSets[0].Resources.Length > 0) { var route = response.ResourceSets[0].Resources[0] as BingMapsRESTToolkit.Route; var locs = new LocationCollection(); for (var i = 0; i < route.RoutePath.Line.Coordinates.Length; i++) { locs.Add(new Location(route.RoutePath.Line.Coordinates[i][0], route.RoutePath.Line.Coordinates[i][1])); } Random random = new Random(); System.Windows.Media.Color randomColor = System.Windows.Media.Color.FromArgb(255, (byte)random.Next(0, 256), (byte)random.Next(0, 256), (byte)random.Next(0, 256)); var routeLine = new MapPolyline() { Locations = locs, Stroke = new SolidColorBrush(randomColor), StrokeThickness = 3 }; RouteLayer.Children.Add(routeLine); } }
private async void UpdateRoute(Location loc) { RouteLayer.Children.Clear(); var startCoord = LocationToCoordinate(StartPin.Location); var endCoord = LocationToCoordinate(EndPin.Location); //Calculate a route between the start and end pushpin. var response = await BingMapsRESTToolkit.ServiceManager.GetResponseAsync(new BingMapsRESTToolkit.RouteRequest() { Waypoints = new List <BingMapsRESTToolkit.SimpleWaypoint>() { new BingMapsRESTToolkit.SimpleWaypoint(startCoord), new BingMapsRESTToolkit.SimpleWaypoint(endCoord) }, BingMapsKey = SessionKey, RouteOptions = new BingMapsRESTToolkit.RouteOptions() { RouteAttributes = new List <BingMapsRESTToolkit.RouteAttributeType> { //Be sure to return the route path information so that we can draw the route line. BingMapsRESTToolkit.RouteAttributeType.RoutePath } } }); if (response != null && response.ResourceSets != null && response.ResourceSets.Length > 0 && response.ResourceSets[0].Resources != null && response.ResourceSets[0].Resources.Length > 0) { var route = response.ResourceSets[0].Resources[0] as BingMapsRESTToolkit.Route; //Generate a Polyline from the route path information. var locs = new LocationCollection(); for (var i = 0; i < route.RoutePath.Line.Coordinates.Length; i++) { locs.Add(new Location(route.RoutePath.Line.Coordinates[i][0], route.RoutePath.Line.Coordinates[i][1])); } var routeLine = new MapPolyline() { Locations = locs, Stroke = new SolidColorBrush(Colors.Blue), StrokeThickness = 3 }; RouteLayer.Children.Add(routeLine); } }
private void DrawCircle() { DrawCircleCenter(); var locations = GetCircle(_latitude, _longitude, _radius); var locationCollection = new LocationCollection(); foreach (var location in locations) { locationCollection.Add(location); } Locations = locationCollection; }
private LocationCollection LocationsFromCoords(double[][] coords) { LocationCollection locations = new LocationCollection(); for (int i = 0; i < coords.Length; i++) { var curCoord = coords[i]; Location loc = new Location(curCoord[1], curCoord[0]); locations.Add(loc); } return(locations); }
private async Task <LocationCollection> ComputeRoute() { var collection = new LocationCollection { CurrentCoordinates }; var fullroute = await IPHelper.GetFullRoute(Connection.TargetIP).ConfigureAwait(false); foreach (var location in fullroute.Select(ip => IPToLocation(ip)).Where(l => l.Latitude != 0 && l.Longitude != 0)) { collection.Add(location); } return(collection); }
private void DrawLine(List <Coordonnees> liste, int id, Color col) //DESSINE LES LIGNES ENTRES LES COORDONNEES DE LA POLYLINE { LocationCollection loc = new LocationCollection(); for (int i = 0; i < liste.Count; i++) { if (i + 1 < liste.Count) { Location loc1 = new Location(liste[i].Latitude, liste[i].Longitude); Location loc2 = new Location(liste[i + 1].Latitude, liste[i + 1].Longitude); loc.Add(loc1); loc.Add(loc2); } } MapPolyline line = new MapPolyline(); line.Stroke = new SolidColorBrush(col); line.StrokeThickness = 3.0; line.Locations = loc; line.Tag = id.ToString(); MyMap.Children.Add(line); }
public async void Handle(Viaggio message) { Location posPartenza = new Location(message.LatitudinePartenzaPrevista, message.LongitudinePartenzaPrevista); Location posArrivo = new Location(message.LatitudineArrivoPrevista, message.LongitudineArrivoPrevista); MapLayer.SetPosition(posizioneStart, posPartenza); MapLayer.SetPosition(posizioneEnd, posArrivo); LocationCollection lc = new LocationCollection(); lc.Add(posPartenza); lc.Add(posArrivo); while (mappaBing.ActualWidth < 1) { await Task.Delay(TimeSpan.FromMilliseconds(10)); } var bounds = new LocationRect(lc); mappaBing.SetView(bounds.Center, AdattaZoomMappa(lc, mappaBing.ActualWidth, mappaBing.ActualHeight, 10)); }
/// <summary> /// Перепроецирует геометрию в WGS84 и возвращает набор точек /// </summary> /// <param name="input">Простые полигоны и полилинии из БД в системе координать UtmZone31N</param> /// <returns>Набор точек в системе координат WGS84 (SRID 4326)</returns> /// <remarks>Внимание! Многоконтурная геометрия не поддерживается</remarks> public LocationCollection UtmZone31nToWgs84Transform(DbGeometry input) { if (input == null) { return(null); } //Перевод геометрии в формат понятный для библиотеки DotSpatial byte[] wkbBynary = input.AsBinary(); WkbReader wkbReader = new WkbReader(); DotSpatial.Topology.IGeometry geom = wkbReader.Read(wkbBynary); //Определение используемых проекций ProjectionInfo beninPrj = KnownCoordinateSystems.Projected.UtmWgs1984.WGS1984UTMZone31N; ProjectionInfo worldPrj = KnownCoordinateSystems.Geographic.World.WGS1984; //Создание массива точек Х1,У1,Х2,У2...Хn,Уn double[] pointArray = new double[geom.Coordinates.Count() * 2]; double[] zArray = new double[1]; zArray[0] = 0; int counterX = 0; int counterY = 1; foreach (var coordinate in geom.Coordinates) { pointArray[counterX] = coordinate.X; pointArray[counterY] = coordinate.Y; counterX += 2; counterY += 2; } //Операция перепроецирования над массивом точек Reproject.ReprojectPoints(pointArray, zArray, beninPrj, worldPrj, 0, (pointArray.Length / 2)); LocationCollection loc = new LocationCollection(); counterX = 0; counterY = 1; foreach (var coordinate in geom.Coordinates) { loc.Add(new Location(pointArray[counterY], pointArray[counterX])); counterX += 2; counterY += 2; } return(loc); }
public static LocationCollection ToCoordinates(this IEnumerable<Location> points) { var locations = new LocationCollection(); if (points != null) { foreach (var point in points) { locations.Add(point.ToCoordinate()); } } return locations; }
/// <summary> /// Creates the star points. /// </summary> /// <param name="center">The center.</param> /// <returns>The star points.</returns> private LocationCollection CreateStarPoints(Location center ) { var locations = new LocationCollection(); var ir = InnerRadius / 200000; var or = OuterRadius / 200000; var angle = Math.PI / Arms; for (var i = 0; i <= 2 * Arms; i++) { var r = (i & 1) == 0 ? or : ir; locations.Add(new Location(center.Latitude + ((Math.Cos(i * angle) * r) * NorthCompressionFactor), center.Longitude + (Math.Sin(i * angle) * r))); } return locations; }
/// <summary> /// Direction Route completed /// add cross points to polyline /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void routeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e) { LocationCollection loCollect = new LocationCollection(); for (int i = 0; i < e.Result.Geometry.Count; i++) { loCollect.Add(e.Result.Geometry[i]); } MapPolyline routeline = new MapPolyline() { StrokeThickness=8, Locations=loCollect, Stroke=new SolidColorBrush(Colors.Red) }; OnRouteChanged("RouteChanged", routeline); }
internal void addPolyline(IMapPolyline polylineSource, Color color, double width) { // Does it already exist? if (polylines.ContainsKey(polylineSource)) return; LocationCollection lc = new LocationCollection(); foreach (Location loc in polylineSource.Locations) lc.Add(loc); // Add to the UI MapPolyline pl = new MapPolyline() { Locations = lc, Color = color, Width = width }; polylinesLayer.Shapes.Add(pl); // And add to our location collection polylines.Add(polylineSource, pl); }
public static LocationCollection CreateCircle(GeoCoordinate center, double radius) { var earthRadius = 6367000; // radius in meters var lat = ToRadian(center.Latitude); //radians var lng = ToRadian(center.Longitude); //radians var d = radius / earthRadius; // d = angular distance covered on earth's surface var locations = new LocationCollection(); for (var x = 0; x <= 360; x++) { var brng = ToRadian(x); var latRadians = Math.Asin(Math.Sin(lat) * Math.Cos(d) + Math.Cos(lat) * Math.Sin(d) * Math.Cos(brng)); var lngRadians = lng + Math.Atan2(Math.Sin(brng) * Math.Sin(d) * Math.Cos(lat), Math.Cos(d) - Math.Sin(lat) * Math.Sin(latRadians)); locations.Add(new GeoCoordinate(ToDegrees(latRadians), ToDegrees(lngRadians))); } return locations; }
void CreateHex() { if (_hexa.Equals("")) return; GeoHex.Zone zone = GeoHex.GeoHex.Decode(_hexa); GeoHex.Loc[] locations = zone.getHexCoords(); if (locations == null || locations.Count() != 6) return; map1.Center = new GeoCoordinate(zone.lat, zone.lon); var collection = new LocationCollection(); foreach (var location in locations) { var geo = new GeoCoordinate(location.lat, location.lon); collection.Add(geo); } mapPolygon.Locations = collection; PolygonLayer.Visibility = Visibility.Visible; }
public void LoadMap() { ActivityViewModel vm = this.DataContext as ActivityViewModel; MapPolyline line = new MapPolyline(); var locations = new LocationCollection(); foreach (var waypoint in vm.ActivityGpsData.Waypoints) locations.Add(new Location(Convert.ToDouble(waypoint.Latitude), Convert.ToDouble(waypoint.Longitude), Convert.ToDouble(waypoint.Elevation))); line.Locations = locations; line.StrokeThickness = 3; line.Stroke = new SolidColorBrush(Colors.Red); map.Children.Add(line); map.Loaded += (s, e) => { LocationRect boundingBox = new LocationRect(locations); map.SetView(boundingBox); }; }
public BikePaths() { Paths = new List<LocationCollection>(); string xmlString; // Load the bike paths in memory. using (StreamReader reader = new StreamReader(Application.GetResourceStream(new Uri("Data/BikePaths.kml", UriKind.Relative)).Stream)) { xmlString = reader.ReadToEnd(); } // Parse the bike paths into a list of GeoCoordinates. XElement xmlContent = XElement.Load(Application.GetResourceStream(new Uri("Data/BikePaths.kml", UriKind.Relative)).Stream); XNamespace xmlNamespace = "http://www.opengis.net/kml/2.2"; var coordinates = from placemark in xmlContent.Descendants(xmlNamespace + "Placemark") select placemark.Descendants(xmlNamespace + "coordinates").First().Value; foreach (var coordinate in coordinates) { var points = coordinate.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); var collection = new LocationCollection(); foreach (var point in points) { // Get the longitude and latitude out of the string and store it in a way the map can process. var data = point.Split(','); double longitude; double latitude; if (double.TryParse(data[0], out longitude) && double.TryParse(data[1], out latitude)) { collection.Add(new GeoCoordinate(latitude, longitude)); } } Paths.Add(collection); } }
void routeClient_CalculateRouteCompleted(object sender, CalculateRouteCompletedEventArgs e) { string outString; try { if (e.Result.ResponseSummary.StatusCode != RouteService.ResponseStatusCode.Success) { outString = "error routing ... status <" + e.Result.ResponseSummary.StatusCode.ToString() + ">"; } else if (0 == e.Result.Result.Legs.Count) { outString = "Cannot find route"; } else { LocationCollection coll = new LocationCollection(); foreach (Location p in e.Result.Result.RoutePath.Points) { coll.Add(new Location(p.Latitude, p.Longitude)); } Messenger.Default.Send<Messages.RouteDoneMessage>(new Messages.RouteDoneMessage { Legs = e.Result.Result.Legs, Locations = coll}, "RouteDone"); } } catch (Exception) { outString = "Exception raised routine"; } // ToOutput.Text = outString; }
public void EndCalculateRoute(IAsyncResult e) { RouteResponse response = RouteServiceClient.EndCalculateRoute(e); if ((response.ResponseSummary.StatusCode == RouteService.ResponseStatusCode.Success) & (response.Result.Legs.Count != 0)) { LocationCollection locations = new LocationCollection(); foreach (Location p in response.Result.RoutePath.Points) { //add the location also to the location collection locations.Add(p); } this.Locations = locations; this.Distance = response.Result.Summary.Distance; this.Time = (int)response.Result.Summary.TimeInSeconds / 60 * BikeConsts.DRIVE_TO_BIKE; } }
public void UpdateUserRadius(String Radius,Bing.Maps.Location loc) { var R = 6371; var radius = Radius; //radius of the circle var latitude = loc.Latitude; //latitude of the circle center var longitude = loc.Longitude; //longitude of the circle center var lat = (latitude * Math.PI) / 180; var lon = (longitude * Math.PI) / 180; var d = float.Parse(radius) / R; var circlePoints = new LocationCollection(); for (int x = 0; x <= 360; x += 5) { var p2 = new Bing.Maps.Location(0, 0); var brng = x * Math.PI / 180; p2.Latitude = Math.Asin(Math.Sin(lat) * Math.Cos(d) + Math.Cos(lat) * Math.Sin(d) * Math.Cos(brng)); p2.Longitude = ((lon + Math.Atan2(Math.Sin(brng) * Math.Sin(d) * Math.Cos(lat), Math.Cos(d) - Math.Sin(lat) * Math.Sin(p2.Latitude))) * 180) / Math.PI; p2.Latitude = (p2.Latitude * 180) / Math.PI; circlePoints.Add(p2); } userRadius = new LocationRect(circlePoints); var u = 0.001; userRadius = new LocationRect(new LocationCollection{ loc, new Bing.Maps.Location(loc.Latitude+u,loc.Longitude),new Bing.Maps.Location(loc.Latitude,loc.Longitude+u), new Bing.Maps.Location(loc.Latitude+u,loc.Longitude+u), new Bing.Maps.Location(loc.Latitude-u,loc.Longitude), new Bing.Maps.Location(loc.Latitude,loc.Longitude-u), new Bing.Maps.Location(loc.Latitude-u,loc.Longitude-u)}); }
private void DrawCircleCenter() { const double centerRadius = 5; double decreasedRadius = _radius / centerRadius; decreasedRadius = decreasedRadius > centerRadius ? centerRadius : decreasedRadius; var locations = GetCircle(_latitude, _longitude, decreasedRadius); var locationCollection = new LocationCollection(); foreach (var location in locations) { locationCollection.Add(location); } CircleCenter = locationCollection; }
private async void searchPane_QuerySubmitted(SearchBox sender, SearchBoxQuerySubmittedEventArgs args) { //throw new NotImplementedException(); myMap.Children.Clear(); //Logic for geaocding the query text if (!string.IsNullOrWhiteSpace(args.QueryText)) { await new MessageDialog(args.QueryText).ShowAsync(); Uri geocodeUri = new Uri( string.Format("http://dev.virtualearth.net/REST/v1/Locations?q={0}&c={1}&key={2}", Uri.EscapeUriString(args.QueryText), args.Language, myMap.Credentials)); //Get response from Bing Maps REST services Response r = await GetResponse(geocodeUri); if(r != null && r.ResourceSets != null && r.ResourceSets.Length > 0 && r.ResourceSets[0].Resources != null && r.ResourceSets[0].Resources.Length > 0) { LocationCollection locations = new LocationCollection(); int i = 1; foreach(BingMapsRESTService.Common.JSON.Location l in r.ResourceSets[0].Resources) { //Get the Location of each result Bing.Maps.Location location = new Bing.Maps.Location(l.Point.Coordinates[0], l.Point.Coordinates[1]); //Create a pushpin each location Pushpin pin = new Pushpin() { Tag = l.Name, Text = i.ToString() }; i++; //Add a tapped event that will displau the name of the location pin.Tapped += async (s, a) => { var p = s as Pushpin; await new MessageDialog(p.Tag as string).ShowAsync(); }; //Set the location of the pushpin MapLayer.SetPosition(pin, location); //add th pushpin to the map myMap.Children.Add(pin); //Add the coordinates of the location to a location collection locations.Add(location); }//End foreach //set the map view based on the location collection myMap.SetView(new LocationRect(locations)); }//End IF else { await new MessageDialog("Nenhum resultado encontrado..").ShowAsync(); } } }