public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var camera = CameraPosition.FromCamera(-37.81969, 144.966085, 4);

            mapView = MapView.FromCamera(CGRect.Empty, camera);
            View    = mapView;

            BeginInvokeOnMainThread(() => mapView.MyLocationEnabled = true);
            var myLocationButton = new UIBarButtonItem("Fly to My Location", UIBarButtonItemStyle.Plain, DidTapMyLocation);

            NavigationItem.RightBarButtonItem = myLocationButton;
        }
Exemple #2
0
        /// <summary>
        /// Animates the camera.
        /// </summary>
        public void AnimateCamera()
        {
            GlobalLocation globalLocation_Local = new GlobalLocation(this, true);

            if (!string.IsNullOrEmpty(Settings.UserLatSettings))
            {
                camera = CameraPosition.FromCamera(latitude: Convert.ToDouble(Settings.UserLatSettings),
                                                   longitude: Convert.ToDouble(Settings.UserLongSettings), zoom: 12, bearing: 44, viewingAngle: 10);
                if (mapView != null)
                {
                    mapView.MyLocationEnabled = true;
                    mapView.Animate(camera);
                }
            }
        }
 public override void ViewWillTransitionToSize(CGSize toSize, IUIViewControllerTransitionCoordinator coordinator)
 {
     base.ViewWillTransitionToSize(toSize, coordinator);
     if (mapView == null)
     {
         CameraPosition camera = CameraPosition.FromCamera(latitude: 37.797865,
                                                           longitude: -122.402526,
                                                           zoom: 6);
         mapView         = MapView.FromCamera(new CGRect(0, 0, View.Frame.Width, View.Frame.Height - 49), camera);
         mapView.MapType = GetMapType();
         mapView.Settings.MyLocationButton = true;
         mapView.MyLocationEnabled         = true;
     }
     mapView.Frame = new CGRect(0, 0, toSize.Width, toSize.Height - 49);
 }
        public override void LoadView()
        {
            base.LoadView();

            CameraPosition camera = CameraPosition.FromCamera(latitude: 42.392262,
                                                              longitude: -72.526992,
                                                              zoom: 6);

            mapView = MapView.FromCamera(CGRect.Empty, camera);
            mapView.MyLocationEnabled = true;

            View = mapView;

            mapView.CoordinateLongPressed += HandleLongPress;
        }
Exemple #5
0
        public override void LoadView()
        {
            var camera = CameraPosition.FromCamera(latitude: -28, longitude: 137, 4);

            mapView   = MapView.FromCamera(frame: CGRect.Empty, camera: camera);
            this.View = mapView;

            var path = NSBundle.PathForResourceAbsolute("GeoJSON_sample", "json", NibBundle.BundlePath);
            var url  = NSUrl.CreateFileUrl(path, null);

            geoJsonParser = new GMUGeoJSONParser(url);
            geoJsonParser.Parse();

            renderer = new GMUGeometryRenderer(map: mapView, geometries: geoJsonParser.Features);

            renderer.Render();
        }
Exemple #6
0
        public override void LoadView()
        {
            base.LoadView();

            CameraPosition camera = CameraPosition.FromCamera(37.797865, -122.402526, 6);

            mapView = MapView.FromCamera(RectangleF.Empty, camera);
            mapView.MyLocationEnabled = true;

            mapView.AddMarker(new MarkerOptions {
                Title    = "Xamarin HQ",
                Snippet  = "Where the magic happens.",
                Position = new CLLocationCoordinate2D(37.797865, -122.402526)
            });

            View = mapView;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var camera = CameraPosition.FromCamera(-33.868, 151.2086, 12);

            mapView = MapView.FromCamera(RectangleF.Empty, camera);
            mapView.Settings.CompassButton    = true;
            mapView.Settings.MyLocationButton = true;

            // Listen to the myLocation property of GMSMapView.
            mapView.AddObserver(this, new NSString("myLocation"), NSKeyValueObservingOptions.New, IntPtr.Zero);

            View = mapView;
            // Ask for My Location data after the map has already been added to the UI.
            InvokeOnMainThread(() => mapView.MyLocationEnabled = true);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            MapView    = new MapView();
            DoneButton = new UIButton
            {
                BackgroundColor = Colors.PickupButtonColor,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            DoneButton.SetTitle(GetDoneButtonTitle(), UIControlState.Normal);

            CenterPinImageView = new UIImageView(GetPinImage())
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            View.AddSubviews(MapView, CenterPinImageView, DoneButton);

            SetupConstraints();

            var searchTextField = this.CreateSearchViewOnNavigationBar(ViewModel);

            searchTextField.ClearButtonMode    = UITextFieldViewMode.Never;
            searchTextField.ShouldBeginEditing = _ => false;

            this.SetBinding(
                () => MapView.Camera,
                () => ViewModel.CameraTarget, BindingMode.TwoWay)
            .ConvertTargetToSource(location =>
                                   CameraPosition.FromCamera(location.Latitude, location.Longitude, 16));

            ViewModel.CameraPositionChanged = Observable
                                              .FromEventPattern <EventHandler <GMSCameraEventArgs>, GMSCameraEventArgs>(
                e => MapView.CameraPositionIdle += e,
                e => MapView.CameraPositionIdle -= e)
                                              .Select(e => e.EventArgs.Position.Target)
                                              .Select(c => new Location(c.Latitude, c.Longitude));

            ViewModel.CameraStartMoving = Observable
                                          .FromEventPattern <EventHandler <GMSWillMoveEventArgs>, GMSWillMoveEventArgs>(
                e => MapView.WillMove += e,
                e => MapView.WillMove -= e)
                                          .Select(e => e.EventArgs.Gesture);
        }
        private void RegionMoved(object sender, MapRegionMoveEventArgs e)
        {
            var map = Control;

            if (Math.Abs(map.Camera.Target.Latitude - e.Latitude) < 0.0001 &&
                Math.Abs(map.Camera.Target.Longitude - e.Longitude) < 0.0001 &&
                Math.Abs(map.Camera.Zoom - e.Zoom) < 0.01)
            {
                var position = new CLLocationCoordinate2D(e.Latitude, e.Longitude);
                Map_CoordinateTapped(this, new GMSCoordEventArgs(position));
                Map_CameraPositionIdle(this, new GMSCameraEventArgs(map.Camera));
            }
            else
            {
                var camera = CameraPosition.FromCamera(e.Latitude, e.Longitude, e.Zoom);
                map.Animate(camera);
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var camera = CameraPosition.FromCamera(-25.5605, 133.605097, 3);

            mapView = MapView.FromCamera(CGRect.Empty, camera);
            mapView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

            View = new UIView(CGRect.Empty);
            View.AddSubview(mapView);

            var holder = new UIView(new CGRect(0, 0, 0, 59))
            {
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleBottomMargin,
                BackgroundColor  = UIColor.FromRGBA(1.0f, 1.0f, 1.0f, 0.8f)
            };

            View.AddSubview(holder);

            // Zoom Label
            var label = new UILabel(new CGRect(16, 16, 200, 29))
            {
                Text            = "Zooming?",
                Font            = UIFont.SystemFontOfSize(18.0f),
                TextAlignment   = UITextAlignment.Left,
                BackgroundColor = UIColor.Clear
            };

            label.Layer.ShadowColor   = UIColor.White.CGColor;
            label.Layer.ShadowOffset  = new CGSize(0.0f, 1.0f);
            label.Layer.ShadowOpacity = 1.0f;
            label.Layer.ShadowRadius  = 0.0f;
            holder.AddSubview(label);

            // Control zooming.
            zoomSwitch = new UISwitch(new CGRect(-90, 16, 0, 0))
            {
                AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin
            };
            zoomSwitch.ValueChanged += (sender, e) => mapView.Settings.ZoomGestures = zoomSwitch.On;
            zoomSwitch.On            = true;
            holder.AddSubview(zoomSwitch);
        }
        void InitMapView()
        {
            var myLocation   = LocationHelper.GetLocationResult();
            var myLocation2D = new CLLocationCoordinate2D(myLocation.Latitude, myLocation.Longitude);

            var camera = CameraPosition.FromCamera(myLocation2D, zoom: PortableLibrary.Constants.MAP_ZOOM_LEVEL);

            mMapView = MapView.FromCamera(RectangleF.Empty, camera);
            mMapView.MyLocationEnabled = false;

            mMapView.TappedMarker = ClickedDropItem;

            markerMyLocation = new Marker
            {
                Position = myLocation2D,
                Map      = mMapView,
                Icon     = UIImage.FromFile("pin_me.png")
            };
        }
        private void Scrolll_Scrolled(object sender, EventArgs e)
        {
            var PageeIndex = (double)(Scrolll.ContentOffset.X / Scrolll.Frame.Width);

            if (PageeIndex % 1 == 0)
            {
                try
                {
                    var newCamera = CameraPosition.FromCamera(OlusanMarkerlar[(int)PageeIndex].Position, 12, mapView.Camera.Bearing + 10, mapView.Camera.ViewingAngle + 10);
                    mapView.Animate(newCamera);
                }
                catch
                {
                }
            }
            else
            {
            }
        }
        public override void LoadView()
        {
            var camera = CameraPosition.FromCamera(latitude: 37.4220, longitude: -122.0841, 17);

            mapView   = MapView.FromCamera(frame: CGRect.Empty, camera: camera);
            this.View = mapView;

            var path = NSBundle.PathForResourceAbsolute("KML_Sample", "kml", NibBundle.BundlePath);
            var url  = NSUrl.CreateFileUrl(path, null);

            kmlParser = new GMUKMLParser(url);
            kmlParser.Parse();

            renderer = new GMUGeometryRenderer(map: mapView,
                                               geometries: kmlParser.Placemarks,
                                               styles: kmlParser.Styles);

            renderer.Render();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var newark  = new CLLocationCoordinate2D(40.742, -74.174);
            var camera  = CameraPosition.FromCamera(newark, 12, 0, 50);
            var mapView = MapView.FromCamera(RectangleF.Empty, camera);

            // Image from http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg
            var groundOverlay = new GroundOverlay()
            {
                Icon      = UIImage.FromBundle("newark_nj_1922.jpg"),
                Position  = newark,
                Bearing   = 0,
                ZoomLevel = 13.6f,
                Map       = mapView
            };

            View = mapView;
        }
Exemple #15
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var camera = CameraPosition.FromCamera(-37.81969, 144.966085, 4);

            mapView = MapView.FromCamera(CGRect.Empty, camera);
            AddDefaultMarkers();

            // Add a button which adds random markers to the map.
            var addButton   = new UIBarButtonItem(UIBarButtonSystemItem.Add, DidTapAdd);
            var clearButton = new UIBarButtonItem("Clear Markers", UIBarButtonItemStyle.Plain, (o, s) => {
                mapView.Clear();
                AddDefaultMarkers();
            });

            NavigationItem.RightBarButtonItems = new [] { addButton, clearButton };

            View = mapView;
        }
Exemple #16
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            CameraPosition Camera = CameraPosition.FromCamera(41.887, -87.622, 15, 30, 40); //Se instalancia el CLLocationCoordinate2D con la ubicación, el angulo y la altura que va a tener la unicación.

            Mapa = MapView.FromCamera(CGRect.Empty, Camera);                                //la pantalla o mapa la queremos ver en toda la pantalla, colocamos CGRect.Empty

            var Marcador = new Marker()                                                     //Un marcador para agregar en el mapa
            {
                Title           = "Chicago",
                Icon            = UIImage.FromFile("IconMaps.png"),
                AppearAnimation = MarkerAnimation.Pop,
                Snippet         = "Ciudad de Chicago - N0rf3n",
                Position        = new CLLocationCoordinate2D(41.887, -87.622),
                Map             = Mapa
            };

            Mapa.SelectedMarker = Marcador; //como ya se tiene el marcado se agrega al mapa.
            View = Mapa;
        }
Exemple #17
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var set = this.CreateBindingSet <MapView, MapViewModel>();

            set.Apply();
            CameraPosition camera = CameraPosition.FromCamera(GetInitialCameraPosition(),
                                                              GetInitialCameraZoom());

            mapView = Google.Maps.MapView.FromCamera(CGRect.Empty, camera);
            mapView.MyLocationEnabled         = true;
            mapView.Settings.MyLocationButton = true;
            mapView.CameraPositionIdle       += MapView_CameraPositionIdle;
            mapView.InfoTapped       += MapView_InfoTapped;
            mapView.CoordinateTapped += MapView_CoordinateTapped;
            //mapView.WillMove += MapView_WillMove;
            ViewModel.Items.Changed += ItemsChanged;
            View.AddSubview(mapView);
            mapView.Frame = MapPlaceHolderView.Frame;

            var iconGenerator = new GMUDefaultClusterIconGenerator();
            var algorithm     = new GMUNonHierarchicalDistanceBasedAlgorithm();

            renderer = new GMUDefaultClusterRenderer(mapView, iconGenerator)
            {
                Delegate = new JunctionXClusterRendererDelegate(this)
            };

            clusterManager        = new GMUClusterManager(mapView, algorithm, renderer);
            mapView.TappedMarker += (map, marker) => SelectMarker(marker);

            ActivityButton.TouchDown  += ActivityButton_TouchDown;
            ActivityButton2.TouchDown += ActivityButton_TouchDown;
            AdoptButton.TouchDown     += AdoptButton_TouchDown;
            DetailsButton.TouchDown   += DetailsButton_TouchDown;
            DetailsButton2.TouchDown  += DetailsButton_TouchDown;
            CloseButton.TouchDown     += CloseButton_TouchDown;

            //var gest = new UITapGestureRecognizer(() => { View.SendSubviewToBack(MarkerInfoView);});
            //TapView.AddGestureRecognizer(gest);
        }
Exemple #18
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            mapView = new MapView(this.View.Bounds);

            myDel = new GoogleMapsDelegate();
            CameraPosition camera = CameraPosition.FromCamera(new CoreLocation.CLLocationCoordinate2D(41.013792f, 28.971761f), 13);

            mapView.Camera            = camera;
            mapView.MyLocationEnabled = true;
            mapView.Delegate          = myDel;

            this.View.InsertSubview(mapView, 0);

            Marker aMarker = new Marker();

            aMarker.Position = new CoreLocation.CLLocationCoordinate2D(41.033672f, 28.976482f);
            //aMarker.Snippet = "Test Snippet";//(string)aLocation["name"];
            aMarker.AppearAnimation = MarkerAnimation.Pop;
            aMarker.Map             = mapView;
        }
Exemple #19
0
        public override void LoadView()
        {
            base.LoadView();

            CameraPosition camera = CameraPosition.FromCamera(37.797865, -122.402526, 6);

            mapView = MapView.FromCamera(CGRect.Empty, camera);
            mapView.MyLocationEnabled = true;

            var xamMarker = new Marker()
            {
                Title    = "Xamarin HQ",
                Snippet  = "Where the magic happens.",
                Position = new CLLocationCoordinate2D(37.797865, -122.402526),
                Map      = mapView
            };

            mapView.SelectedMarker = xamMarker;

            View = mapView;
        }
Exemple #20
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            stationsRepository = new WebStationRepository();

            var centerPoint      = Station.TroncalRouteCenter;
            var centerCoordinate = new CLLocationCoordinate2D(centerPoint.Y, centerPoint.X);
            var bounds           = UIScreen.MainScreen.Bounds;

            CameraPosition cameraPosition = CameraPosition.FromCamera(centerCoordinate, 14.0f);
            var            map            = MapView.FromCamera(new RectangleF(0, 64, bounds.Width, bounds.Height - 60), cameraPosition);

            map.MyLocationEnabled         = true;
            map.MapType                   = MapViewType.Normal;
            map.Settings.MyLocationButton = true;

            this.mapView = map;
            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                NavigationBar.Frame = new RectangleF(NavigationBar.Frame.X, NavigationBar.Frame.Y, NavigationBar.Frame.Width, 64.0f);
            }

            var             item   = new UINavigationItem("CHART");
            UIBarButtonItem button = new UIBarButtonItem(MainViewController.ResizedImageIcon(UIImage.FromFile("menu.png")), UIBarButtonItemStyle.Bordered, delegate {
                navigation.ToggleMenu();
            });
            UIBarButtonItem closestStationButton = new UIBarButtonItem("Cercana", UIBarButtonItemStyle.Bordered, delegate {
                FindClosestStation();
            });

            item.LeftBarButtonItem  = button;
            item.HidesBackButton    = true;
            item.RightBarButtonItem = closestStationButton;
            NavigationBar.PushNavigationItem(item, false);

            notificationView = new GCDiscreetNotificationView("Buscando estación cercana...",
                                                              true, GCDNPresentationMode.Bottom, mapView);
            this.View.AddSubview(map);
            LoadMapInfo();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var camera  = CameraPosition.FromCamera(39.13006, -77.508545, 4);
            var mapView = MapView.FromCamera(CGRect.Empty, camera);

            // Create the first polygon.
            var polygon = new Polygon()
            {
                Path        = PathOfNewYorkState(),
                Title       = "New York",
                FillColor   = UIColor.FromRGBA(0.25f, 0, 0, 0.05f),
                StrokeColor = UIColor.Black,
                StrokeWidth = 2,
                Tappable    = true,
                Map         = mapView
            };

            // Copy the existing polygon and its settings and use it as a base for the
            // second polygon.

            polygon           = (Polygon)polygon.Copy();
            polygon.Title     = "North Carolina";
            polygon.Path      = PathOfNorthCarolina();
            polygon.FillColor = UIColor.FromRGBA(0, 0.25f, 0, 0.05f);
            polygon.Map       = mapView;

            mapView.OverlayTapped += (sender, e) => {
                // When a polygon is tapped, randomly change its fill color to a new hue.
                if (e.Overlay is Polygon)
                {
                    var pol = e.Overlay as Polygon;
                    var hue = GetRandomNumber();
                    pol.FillColor = UIColor.FromHSBA(hue, 1, 1, 0.05f);
                }
            };

            View = mapView;
        }
        async Task <string> GeocodeToConsoleAsync(string address)
        {
            var geoCoder = new CLGeocoder();

            CLPlacemark[] placemarks = null;
            try
            {
                placemarks = await geoCoder.GeocodeAddressAsync(address);
            }
            catch
            {
                if (!methods.IsConnected())
                {
                    InvokeOnMainThread(() =>
                    {
                        NoConnectionViewController.view_controller_name = GetType().Name;
                        this.NavigationController.PushViewController(sb.InstantiateViewController(nameof(NoConnectionViewController)), false);
                        return;
                    });
                }
                return(null);
            }
            foreach (var placemark in placemarks)
            {
                Console.WriteLine(placemark);
                CLLocationCoordinate2D coord = new CLLocationCoordinate2D(placemark.Location.Coordinate.Latitude, placemark.Location.Coordinate.Longitude);
                var marker = Marker.FromPosition(coord);
                //marker.Title = string.Format("Marker 1");
                marker.Icon = UIImage.FromBundle("add_loc_marker.png");
                marker.Map  = mapView;
                camera      = CameraPosition.FromCamera(latitude: Convert.ToDouble(placemark.Location.Coordinate.Latitude, CultureInfo.InvariantCulture),
                                                        longitude: Convert.ToDouble(placemark.Location.Coordinate.Longitude, CultureInfo.InvariantCulture),
                                                        zoom: zoom);
                lat_temporary  = placemark.Location.Coordinate.Latitude.ToString().Replace(',', '.');
                lng_temporary  = placemark.Location.Coordinate.Longitude.ToString().Replace(',', '.');
                mapView.Camera = camera;
                break;
            }
            return("");
        }
Exemple #23
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var camera = CameraPosition.FromCamera(-33.868, 151.2086, 12);

            mapView = MapView.FromCamera(CGRect.Empty, camera);
            View    = mapView;

            // The possible different types to show.
            // Create a UISegmentedControl that is the navigationItem's titleView.
            switcher = new UISegmentedControl(new [] { "Normal", "Satellite", "Hybrid", "Terrain" })
            {
                AutoresizingMask = UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleBottomMargin,
                SelectedSegment  = 0,
                ControlStyle     = UISegmentedControlStyle.Bar
            };
            NavigationItem.TitleView = switcher;

            // Listen to touch events on the UISegmentedControl.
            switcher.ValueChanged += HandleValueChanged;
        }
Exemple #24
0
        public void GetMap(UIView _mapView)
        {
            CameraPosition camera = CameraPosition.FromCamera(new CLLocationCoordinate2D(GelenMekan.coordinateX, GelenMekan.coordinateY), 6);

            mapView = MapView.FromCamera(CGRect.Empty, camera);
            mapView.MyLocationEnabled = true;


            mapView.MapStyle = MapStyle.FromJson(ReadFile(), null);
            mapView.Frame    = _mapView.Bounds;
            _mapView.AddSubview(mapView);

            var xamMarker = new Marker()
            {
                Title    = "",
                Snippet  = "",
                Position = new CLLocationCoordinate2D(GelenMekan.coordinateX, GelenMekan.coordinateY),
                Map      = mapView
            };

            mapView.SelectedMarker = xamMarker;
        }
        public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
        {
            try
            {
                currentLocation = change.ObjectForKey(NSValue.ChangeNewKey) as CLLocation;
                if (!isFirst)
                {
                    mapView.Animate(new CameraPosition(new CLLocationCoordinate2D(currentLocation.Coordinate.Latitude, currentLocation.Coordinate.Longitude), mapView.Camera.Zoom, mapView.Camera.Bearing, mapView.Camera.ViewingAngle));
                }
                else
                {
                    mapView.Camera = CameraPosition.FromCamera(currentLocation.Coordinate, 16.00f);
                    isFirst        = false;
                }

                CheckTollRoad();
            }
            catch (Exception)
            {
                //TODO: Burası Sisteme Loglanıcak.
            }
        }
Exemple #26
0
        public async override void LoadView()
        {
            base.LoadView();

            if (MapViewViewModel.LocationService.IsListening)
            {
                await MapViewViewModel.LocationService.StopListeningAsync();

                tracking = false;
            }
            else
            {
                //Positions.Clear();
                if (await MapViewViewModel.LocationService.StartListeningAsync(TimeSpan.FromSeconds(1), 50))
                {
                    //labelGPSTrack.Text = "Started tracking";
                    //ButtonTrack.Text = "Stop Tracking";
                    tracking = true;
                }
            }

            CameraPosition camera = CameraPosition.FromCamera(37.797865, -122.402526, 10);

            mapView = MapView.FromCamera(CGRect.Empty, camera);
            mapView.MyLocationEnabled = true;

            xamMarker = new Marker()
            {
                Title   = "Xamarin HQ",
                Snippet = "Where the magic happens.",
                Icon    = UIImage.FromBundle("car.png"),
                Map     = mapView
            };

            mapView.SelectedMarker = xamMarker;

            View = mapView;
        }
Exemple #27
0
        private void LocationManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
        {
            CameraPosition cp = CameraPosition.FromCamera(e.Locations[0].Coordinate, 15);

            currentLocation = e.Locations[0].Coordinate;

            if (string.IsNullOrEmpty(status))
            {
                googleMap.Animate(cp);
            }

            // Updates drivers current location as location changes while he waits for a request
            if (availabiltyListener != null)
            {
                if (avalability)
                {
                    availabiltyListener.UpdateLocation(currentLocation);
                }
            }

            if (status == "ACCEPTED")
            {
                //Update and Animate driver movement to pick up location
                var pickupLatLng = new CLLocationCoordinate2D(newRideDetails.PickupLat, newRideDetails.PickLng);
                mapHelper.UpdateMovement(currentLocation, pickupLatLng, "Rider");
                newtripListener.UpdateLocation(currentLocation);
            }
            else if (status == "ONTRIP")
            {
                var destinationLatLng = new CLLocationCoordinate2D(newRideDetails.DestinationLat, newRideDetails.DestinationLng);

                // Update and Animate driver movement to destination
                mapHelper.UpdateMovement(currentLocation, destinationLatLng, "destination");

                //Update Location on Firebase
                newtripListener.UpdateLocation(currentLocation);
            }
        }
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);
            if (AppDataHelper.thisPlace != null)
            {
                if (addressRequest == 1)
                {
                    pickupAddress = AppDataHelper.thisPlace.result.name;
                    pickupButtonBar.SetTitle(pickupAddress, UIControlState.Normal);

                    // Move Marker to Pickup Point
                    pickuplocationLatLng = new CLLocationCoordinate2D(AppDataHelper.thisPlace.result.geometry.location.lat, AppDataHelper.thisPlace.result.geometry.location.lng);
                    CameraPosition cp = CameraPosition.FromCamera(pickuplocationLatLng.Latitude, pickuplocationLatLng.Longitude, 15);
                    googleMap.Animate(cp);

                    // Set Address request and change center marker color
                    centerMarker.Image     = centerMarker.Image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
                    centerMarker.TintColor = UIColor.FromRGBA(64, 183, 76, 255);
                }
                else if (addressRequest == 2)
                {
                    destinationAddress = AppDataHelper.thisPlace.result.name;
                    destinationButtonBar.SetTitle(destinationAddress, UIControlState.Normal);

                    // Move Marker to Pickup Point
                    destinationLatLng = new CLLocationCoordinate2D(AppDataHelper.thisPlace.result.geometry.location.lat, AppDataHelper.thisPlace.result.geometry.location.lng);
                    CameraPosition cp = CameraPosition.FromCamera(destinationLatLng.Latitude, destinationLatLng.Longitude, 15);
                    googleMap.Animate(cp);

                    // Set Address request and change center marker color
                    centerMarker.Image           = centerMarker.Image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
                    centerMarker.TintColor       = UIColor.FromRGBA(251, 24, 24, 255);
                    favouritePlacesButton.Hidden = true;
                    doneButton.Hidden            = false;
                }
            }
        }
Exemple #29
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var tap = new UITapGestureRecognizer(() => { View.EndEditing(true); });

            View.AddGestureRecognizer(tap);

            txtMapCard.ShouldReturn  += TextFieldShouldReturn;
            txtMapPromo.ShouldReturn += TextFieldShouldReturn;

            btnMapAddCreditCard.SetCustomButton();
            btnMapSelectPromo.SetCustomButton();
            btnMapSelectPromo.TouchUpInside += VerifyPromoCode;

            btnReadyPickup.SetCustomButton();
            btnScheduleARide.SetCustomButton();

            var lResult = LocationHelper.GetLocationResult();

            var camera = CameraPosition.FromCamera(latitude: lResult.Latitude,
                                                   longitude: lResult.Longitude,
                                                   zoom: 14);

            mapView = MapView.FromCamera(RectangleF.Empty, camera);
            mapView.MyLocationEnabled = false;

            timer = new Timer(ttimerCallback, null, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(60));

            SetBindings();
            if (IsFirstTime)
            {
                IsFirstTime = false;
                SetBindingOnce();
            }
        }
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            InitElements();

            if (!databaseMethods.GetShowMapHint())
            {
                hintView.Hidden = true;
            }
            okBn.TouchUpInside += (s, e) =>
            {
                hintView.Hidden = true;
            };
            neverShowBn.TouchUpInside += (s, e) =>
            {
                hintView.Hidden = true;
                databaseMethods.InsertMapHint(false);
            };

            backBn.TouchUpInside += (s, e) =>
            {
                this.NavigationController.PopViewController(true);
            };
            camera = CameraPosition.FromCamera(latitude: Convert.ToDouble(lat, CultureInfo.InvariantCulture),
                                               longitude: Convert.ToDouble(lng, CultureInfo.InvariantCulture),
                                               zoom: zoom);
            mapView                        = MapView.FromCamera(CGRect.Empty, camera);
            mapView.Frame                  = new Rectangle(0, Convert.ToInt32(headerView.Frame.Height), Convert.ToInt32(View.Frame.Width), Convert.ToInt32(View.Frame.Height));
            mapView.MyLocationEnabled      = true;
            mapView.CoordinateLongPressed += HandleLongPress;
            mapView.UserInteractionEnabled = true;
            setMoscowCameraView();
            applyAddressBn.BackgroundColor = UIColor.FromRGB(255, 99, 62);
            applyAddressBn.Frame           = new Rectangle(Convert.ToInt32(View.Frame.Width) / 15,
                                                           (Convert.ToInt32(View.Frame.Height - View.Frame.Height / 10)),
                                                           Convert.ToInt32(View.Frame.Width) - ((Convert.ToInt32(View.Frame.Width) / 15) * 2),
                                                           Convert.ToInt32(View.Frame.Height) / 12);

            if (!methods.IsConnected())
            {
                NoConnectionViewController.view_controller_name = GetType().Name;
                this.NavigationController.PushViewController(sb.InstantiateViewController(nameof(NoConnectionViewController)), false);
                return;
            }
            address_textView.Hidden = true;
            View.AddSubviews(mapView, centerPositionBn, applyAddressBn, /*address_textView,*/ hintView);

            var mgr = new CLLocationManager();

            try
            {
                var lati = mgr.Location.Coordinate.Latitude.ToString().Replace(',', '.');
                var lngi = mgr.Location.Coordinate.Longitude.ToString().Replace(',', '.');

                camera = CameraPosition.FromCamera(latitude: Convert.ToDouble(lati, CultureInfo.InvariantCulture),
                                                   longitude: Convert.ToDouble(lngi, CultureInfo.InvariantCulture),
                                                   zoom: zoom);
                mapView.Camera = camera;
            }
            catch { }
            bool updated = false;

            mgr.LocationsUpdated += (sender, e) =>
            {
                if (!updated)
                {
                    foreach (var locss in e.Locations)
                    {
                        var lati = e.Locations[0].Coordinate.Latitude.ToString().Replace(',', '.');
                        var lngi = e.Locations[0].Coordinate.Longitude.ToString().Replace(',', '.');
                        camera = CameraPosition.FromCamera(latitude: Convert.ToDouble(lati, CultureInfo.InvariantCulture),
                                                           longitude: Convert.ToDouble(lngi, CultureInfo.InvariantCulture),
                                                           zoom: zoom);

                        try
                        {
                            if (!String.IsNullOrEmpty(lat) && !String.IsNullOrEmpty(lng))
                            {
                                camera = CameraPosition.FromCamera(latitude: Convert.ToDouble(lat, CultureInfo.InvariantCulture),
                                                                   longitude: Convert.ToDouble(lng, CultureInfo.InvariantCulture),
                                                                   zoom: zoom);
                            }
                        }
                        catch { }
                        if (String.IsNullOrEmpty(lat_temporary) && String.IsNullOrEmpty(lng_temporary))
                        {
                            mapView.Camera = camera;
                        }
                    }
                }
                updated = true;
            };
            mgr.StartUpdatingLocation();
            centerPositionBn.TouchUpInside += (s, e) =>
            {
                mgr = new CLLocationManager();
                try
                {
                    var latitude  = mgr.Location.Coordinate.Latitude.ToString().Replace(',', '.');
                    var longitude = mgr.Location.Coordinate.Longitude.ToString().Replace(',', '.');

                    camera = CameraPosition.FromCamera(latitude: Convert.ToDouble(latitude, CultureInfo.InvariantCulture),
                                                       longitude: Convert.ToDouble(longitude, CultureInfo.InvariantCulture),
                                                       zoom: zoom);
                    mapView.Camera = camera;
                }
                catch { }
            };

            try
            {
                if (lat == null && lng == null)
                {
                    try
                    {
                        var sd = await GeocodeToConsoleAsync(HomeAddressViewController.FullAddressTemp);
                    }
                    catch
                    {
                        if (!methods.IsConnected())
                        {
                            InvokeOnMainThread(() =>
                            {
                                NoConnectionViewController.view_controller_name = GetType().Name;
                                this.NavigationController.PushViewController(sb.InstantiateViewController(nameof(NoConnectionViewController)), false);
                                return;
                            });
                        }
                        return;
                    }
                }
                else
                {
                    CLLocationCoordinate2D coord = new CLLocationCoordinate2D(Convert.ToDouble(lat, CultureInfo.InvariantCulture), Convert.ToDouble(lng, CultureInfo.InvariantCulture));
                    var marker = Marker.FromPosition(coord);
                    //marker.Title = string.Format("Marker 1");
                    marker.Icon = UIImage.FromBundle("add_loc_marker.png");
                    marker.Map  = mapView;
                    camera      = CameraPosition.FromCamera(latitude: Convert.ToDouble(lat, CultureInfo.InvariantCulture),
                                                            longitude: Convert.ToDouble(lng, CultureInfo.InvariantCulture),
                                                            zoom: zoom);
                    mapView.Camera = camera;
                }
            }
            catch { }
            applyAddressBn.TouchUpInside += (s, e) =>
            {
                HomeAddressViewController.changedSomething = true;
                if (!String.IsNullOrEmpty(lat_temporary) && !String.IsNullOrEmpty(lng_temporary))
                {
                    lat = lat_temporary;
                    lng = lng_temporary;
                }
                else
                {
                    try
                    {
                        lat = mgr.Location.Coordinate.Latitude.ToString().Replace(',', '.');
                        lng = mgr.Location.Coordinate.Longitude.ToString().Replace(',', '.');
                    }
                    catch { }
                }
                HomeAddressViewController.came_from_map = true;
                this.NavigationController.PopViewController(true);
            };
        }