private void CreateRoute(object sender, EventArgs e) { StopRoute(); NCDeviceInfo res = navigineCore.DeviceInfo; NCSublocation sublocation = navigineCore.Location.Sublocations.GetItem <NCSublocation>(currentSublocationIndex); CGSize imageSizeInMeters = new CGSize(sublocation.Width, sublocation.Height); double xPoint = pressedRoutePin.CenterX() / (mapView.Width() / scrollView.ZoomScale) * imageSizeInMeters.Width; double yPoint = (1.0f - pressedRoutePin.CenterY() / (mapView.Height() / scrollView.ZoomScale)) * imageSizeInMeters.Height; NCLocationPoint point = NCLocationPoint.PointWithLocation(res.Location, res.Sublocation, xPoint, yPoint); activeRoutePin = new RouteMapPin(); activeRoutePin.SetImage(UIImage.FromBundle("MapUser"), UIControlState.Normal); activeRoutePin.SetImage(UIImage.FromBundle("MapUser"), UIControlState.Highlighted); activeRoutePin.SizeToFit(); mapView.AddSubview(activeRoutePin); scrollView.BringSubviewToFront(activeRoutePin); activeRoutePin.Center = pressedRoutePin.Center; if (pressedRoutePin != null) { pressedRoutePin.PopUp.RemoveFromSuperview(); pressedRoutePin.RemoveFromSuperview(); } navigineCore.AddTatget(point); isRouting = true; cancelRouteButton.Hidden = false; }
private void DrawZones() { NCZone[] zones = currentSublocation.Zones; foreach (NCZone zone in zones) { UIBezierPath zonePath = new UIBezierPath(); CAShapeLayer zoneLayer = new CAShapeLayer(); NCLocationPoint[] points = zone.Points; NCLocationPoint point0 = points[0]; zonePath.MoveTo(new CGPoint(mapView.Frame.Width * point0.X.DoubleValue / currentSublocation.Width, mapView.Frame.Height * (1.0 - point0.Y.DoubleValue / currentSublocation.Height))); foreach (NCLocationPoint point in zone.Points) { zonePath.AddLineTo(new CGPoint(mapView.Frame.Width * point.X.DoubleValue / currentSublocation.Width, mapView.Frame.Height * (1.0 - point.Y.DoubleValue / currentSublocation.Height))); } zonePath.AddLineTo(new CGPoint(mapView.Frame.Width * point0.X.DoubleValue / currentSublocation.Width, mapView.Frame.Height * (1.0 - point0.Y.DoubleValue / currentSublocation.Height))); zoneLayer.Hidden = false; zoneLayer.Path = zonePath.CGPath; zoneLayer.StrokeColor = ColorHelper.FromHex(zone.Color, 1).CGColor; zoneLayer.LineWidth = 2.0f; zoneLayer.LineJoin = CoreAnimation.CAShapeLayer.JoinRound; zoneLayer.FillColor = ColorHelper.FromHex(zone.Color, 0.5f).CGColor; mapView.Layer.AddSublayer(zoneLayer); } }
private void PopUpPressed(object sender, EventArgs e) { StopRoute(); NCDeviceInfo res = navigineCore.DeviceInfo; NCSublocation sublocation = navigineCore.Location.Sublocations.GetItem <NCSublocation>(currentSublocationIndex); CGSize imageSizeInMeters = new CGSize(sublocation.Width, sublocation.Height); double xPoint = pressedPin.CenterX() / (mapView.Width() / scrollView.ZoomScale) * imageSizeInMeters.Width; double yPoint = (1.0f - pressedPin.CenterY() / (mapView.Height() / scrollView.ZoomScale)) * imageSizeInMeters.Height; NCLocationPoint point = NCLocationPoint.PointWithLocation(res.Location, res.Sublocation, xPoint, yPoint); navigineCore.AddTatget(point); pressedPin.PopUp.RemoveFromSuperview(); pressedPin.PopUp.Hidden = true; isRouting = true; cancelRouteButton.Hidden = false; }
private void DrawRouteWithPath(NCLocationPoint[] path, float distance) { // We check that we are close to the finish point of the route if (distance <= 3.0f) { StopRoute(); } else { routeLayer?.RemoveFromSuperLayer(); uipath?.RemoveAllPoints(); uipath = new UIBezierPath(); routeLayer = new CAShapeLayer(); for (int i = 0; i < path.Length; i++) { NCLocationPoint point = path[i]; CGSize imageSizeInMeters = new CGSize(currentSublocation.Width, currentSublocation.Height); double xPoint = (point.X.DoubleValue / imageSizeInMeters.Width) * (mapView.Frame.Width / scrollView.ZoomScale); double yPoint = (1.0f - point.Y.DoubleValue / imageSizeInMeters.Height) * (mapView.Frame.Height / scrollView.ZoomScale); if (i == 0) { uipath.MoveTo(new CGPoint(xPoint, yPoint)); } else { uipath.AddLineTo(new CGPoint(xPoint, yPoint)); } } routeLayer.Hidden = false; routeLayer.Path = uipath.CGPath; routeLayer.StrokeColor = ColorHelper.FromHex("#4AADD4", 1).CGColor; routeLayer.LineWidth = 2.0f; routeLayer.LineJoin = CoreAnimation.CAShapeLayer.JoinRound; routeLayer.FillColor = UIColor.Clear.CGColor; mapView.Layer.AddSublayer(routeLayer); mapView.BringSubviewToFront(deviceView); } }