private List <PointF> PointsToRD(List <Location> List) { List <PointF> ret = new List <PointF>(); foreach (Location loc in List) { ret.Add(Projectie.Geo2RD(loc)); } return(ret); }
private void Initialize(Context c) { // Set the background color the white. This is actually redundant, whilst the map can't be zoomed out more than the size of the view. So this background color won't show. We've kept it in as a safeguard. this.SetBackgroundColor(Color.White); BitmapFactory.Options MapOptions = new BitmapFactory.Options(); // Disable scaling due to memory limitations MapOptions.InScaled = false; // Load the bitmap of the map this.Map = BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.Map, MapOptions); // Initialize the scale and pinch gestures this.ScaleDetector = new ScaleGestureDetector(c, this); this.Touch += this.RegisterTouchEvent; // Initialize the location listener. Use Fine Accuarcy and receive updates as often as possible. LocationManager lm = (LocationManager)c.GetSystemService(Context.LocationService); Criteria crit = new Criteria(); crit.Accuracy = Android.Locations.Accuracy.Fine; string lp = lm.GetBestProvider(crit, true); lm.RequestLocationUpdates(lp, 0, 0.5f, this); // Initialize the sensor manager for the orientation SensorManager sm = (SensorManager)c.GetSystemService(Context.SensorService); sm.RegisterListener(this, sm.GetDefaultSensor(SensorType.Orientation), SensorDelay.Ui); // Set the default map offset to the center of the map this.SetLocation(new PointF((MapView.MapEastRD + MapView.MapWestRD) / 2, (MapView.MapNorthRD + MapView.MapSouthRD) / 2)); // Set the current Location to the last know location try { this.CurrentRDLocation = Projectie.Geo2RD(lm.GetLastKnownLocation(lp)); this.CenterMapToCurrentLocation(); } catch (Exception) { } }
// Location public void OnLocationChanged(Location location) { this.CurrentRDLocation = Projectie.Geo2RD(location); this.Accuracy = location.Accuracy; this.Invalidate(); }