public override void ViewDidLoad () { base.ViewDidLoad (); var camera = CameraPosition.FromCamera (0, -180, 3); var mapView = MapView.FromCamera (CGRect.Empty, camera); // Create a 'normal' polyline. var polyline = new Polyline (); var path = new MutablePath (); path.AddCoordinate (new CLLocationCoordinate2D (37.772323, -122.214897)); path.AddCoordinate (new CLLocationCoordinate2D (21.291982, -157.821856)); path.AddCoordinate (new CLLocationCoordinate2D (-18.142599, 178.431)); path.AddCoordinate (new CLLocationCoordinate2D (-27.46758, 153.0278926)); polyline.Path = path; polyline.StrokeColor = UIColor.Red; polyline.StrokeWidth = 2; polyline.Map = mapView; // Copy the previous polyline, change its color, and mark it as geodesic. polyline = (Polyline) polyline.Copy (); polyline.StrokeColor = UIColor.Green; polyline.Geodesic = true; polyline.Map = mapView; View = mapView; }
public override void ViewDidLoad() { base.ViewDidLoad(); var camera = CameraPosition.FromCamera(0, -180, 3); var mapView = MapView.FromCamera(CGRect.Empty, camera); // Create a 'normal' polyline. var polyline = new Polyline(); var path = new MutablePath(); path.AddCoordinate(new CLLocationCoordinate2D(37.772323, -122.214897)); path.AddCoordinate(new CLLocationCoordinate2D(21.291982, -157.821856)); path.AddCoordinate(new CLLocationCoordinate2D(-18.142599, 178.431)); path.AddCoordinate(new CLLocationCoordinate2D(-27.46758, 153.0278926)); polyline.Path = path; polyline.StrokeColor = UIColor.Red; polyline.StrokeWidth = 2; polyline.Map = mapView; // Copy the previous polyline, change its color, and mark it as geodesic. polyline = (Polyline)polyline.Copy(); polyline.StrokeColor = UIColor.Green; polyline.Geodesic = true; polyline.Map = mapView; View = mapView; }
protected override void DrawPolyline (List<GeoLoc> points) { var path = new MutablePath (); points.ForEach (x => path.AddCoordinate (Utils.GetCLLoc(x))); var polyline = new Polyline { Path = path, Geodesic = true }; if (points == _highlighedPoint.Polyline) { polyline.StrokeColor = UIColor.Blue; polyline.StrokeWidth = 7; } else { polyline.StrokeColor = UIColor.Cyan; polyline.StrokeWidth = 3; } polyline.Map = MapView; _routeLines.Add (polyline); }
protected override void DrawPolyline(List <GeoLoc> points) { var path = new MutablePath(); points.ForEach(x => path.AddCoordinate(Utils.GetCLLoc(x))); var polyline = new Polyline { Path = path, Geodesic = true }; if (points == _highlighedPoint.Polyline) { polyline.StrokeColor = UIColor.Blue; polyline.StrokeWidth = 7; } else { polyline.StrokeColor = UIColor.Cyan; polyline.StrokeWidth = 3; } polyline.Map = MapView; _routeLines.Add(polyline); }
private void SetStationsFromRepository() { stations = stationsRepository.Stations; InvokeOnMainThread(() => { foreach (var station in stations) { var stationPosition = new CLLocationCoordinate2D(station.Latitude, station.Longitude); Marker marker = Marker.FromPosition(stationPosition); marker.Title = station.Name; var stationIcon = UIImage.FromFile("StationImages/" + station.ImageFilename() + ".png"); marker.Icon = MainViewController.ResizedImageIcon(stationIcon); marker.Map = mapView; } var path = new MutablePath(); foreach (var point in Station.TroncalRoutePath) { path.AddCoordinate(new CLLocationCoordinate2D(point.Y, point.X)); } var poliline = Polyline.FromPath(path); poliline.StrokeColor = UIColor.DarkGray; poliline.StrokeWidth = 4.0f; poliline.Map = mapView; }); }
void GetMarkersAndPoints() { System.Threading.ThreadPool.QueueUserWorkItem(delegate { ShowLoadingView(PortableLibrary.Constants.MSG_LOADING_ALL_MARKERS); mEventMarker = GetAllMarkers(eventID); var trackPoints = GetTrackPoints(eventID); HideLoadingView(); InvokeOnMainThread(() => { var boundPoints = new List <CLLocationCoordinate2D>(); if (mEventMarker != null && mEventMarker.markers.Count > 0) { for (int i = 0; i < mEventMarker.markers.Count; i++) { var point = mEventMarker.markers[i]; var imgPin = GetPinIconByType(point.type); var pointLocation = new CLLocationCoordinate2D(point.lat, point.lng); boundPoints.Add(pointLocation); AddMapPin(pointLocation, imgPin, i); } } if (trackPoints != null && trackPoints.Count > 0) { if (trackPoints[0].Count > 0) { var startPoint = trackPoints[0][0]; var endPoint = trackPoints[trackPoints.Count - 1][trackPoints[trackPoints.Count - 1].Count - 1]; var startLocation = new CLLocationCoordinate2D(startPoint.Latitude, startPoint.Longitude); var endLocation = new CLLocationCoordinate2D(endPoint.Latitude, endPoint.Longitude); AddMapPin(startLocation, GetPinIconByType("pSTART"), -1); AddMapPin(endLocation, GetPinIconByType("pFINISH"), -1); } for (int i = 0; i < trackPoints.Count; i++) { var tPoints = trackPoints[i]; var path = new MutablePath(); var polyline = new Polyline(); for (int j = 0; j < tPoints.Count; j++) { var tPoint = tPoints[j]; var tLocation = new CLLocationCoordinate2D(tPoint.Latitude, tPoint.Longitude); if (j < tPoints.Count - 1) { var distance = DistanceAtoB(tPoint, tPoints[j + 1]); if (PortableLibrary.Constants.AVAILABLE_DISTANCE_MAP > distance) { var nPoint = tPoints[j + 1]; path.AddCoordinate(tLocation); } else { polyline.Path = path; polyline.StrokeColor = GetRandomColor(i); polyline.StrokeWidth = 5; polyline.Geodesic = true; polyline.Map = mMapView; path = new MutablePath(); polyline = new Polyline(); } } polyline.Path = path; polyline.StrokeColor = GetRandomColor(i); polyline.StrokeWidth = 5; polyline.Geodesic = true; polyline.Map = mMapView; boundPoints.Add(tLocation); } } } if (boundPoints.Count == 0) { var camera = CameraPosition.FromCamera(PortableLibrary.Constants.LOCATION_ISURAEL[0], PortableLibrary.Constants.LOCATION_ISURAEL[1], zoom: PortableLibrary.Constants.MAP_ZOOM_LEVEL); mMapView = MapView.FromCamera(RectangleF.Empty, camera); } else { var mapBounds = new CoordinateBounds(); foreach (var bound in boundPoints) { mapBounds = mapBounds.Including(bound); } mMapView.MoveCamera(CameraUpdate.FitBounds(mapBounds, 50.0f)); } }); }); }
private void SetStationsFromRepository() { stations = stationsRepository.Stations; InvokeOnMainThread (() => { foreach (var station in stations) { var stationPosition = new CLLocationCoordinate2D(station.Latitude, station.Longitude); Marker marker = Marker.FromPosition(stationPosition); marker.Title = station.Name; var stationIcon = UIImage.FromFile ("StationImages/" + station.ImageFilename () + ".png"); marker.Icon = MainViewController.ResizedImageIcon(stationIcon); marker.Map = mapView; } var path = new MutablePath(); foreach(var point in Station.TroncalRoutePath) { path.AddCoordinate(new CLLocationCoordinate2D(point.Y, point.X)); } var poliline = Polyline.FromPath(path); poliline.StrokeColor = UIColor.DarkGray; poliline.StrokeWidth = 4.0f; poliline.Map = mapView; }); }