示例#1
0
        public MapViewController() : base(nameof(MapViewController), null)
        {
            _map               = new MKMapView(UIScreen.MainScreen.Bounds);
            _coordinateSpace   = _map.CoordinateSpace;
            _map.ZoomEnabled   = true;
            _map.ScrollEnabled = true;

            MarkerListFromRepository = new List <MapMarkerEntity>();

            _marcerRow = new MapMarkerEntity();
        }
示例#2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = base.OnCreateView(inflater, container, savedInstanceState);

            _mapView = (MapView)view.FindViewById(Resource.Id.mapView);

            _mapView.OnCreate(savedInstanceState);

            _mapView.GetMapAsync(this);

            _marcerRow = new MapMarkerEntity();

            return(view);
        }
示例#3
0
        private void ClickOnMap(object sender, GoogleMap.MapClickEventArgs eventArgs)
        {
            using (var markerOption = new MarkerOptions())
            {
                markerOption.SetPosition(eventArgs.Point);
                _marcerRow = new MapMarkerEntity
                {
                    Latitude  = markerOption.Position.Latitude,
                    Longitude = markerOption.Position.Longitude
                };

                ViewModel.SaveMarkerInList(_marcerRow);
                string title = $"{ViewModel.TaskId}";

                markerOption.SetTitle(title);

                Marker marker = _map.AddMarker(markerOption);
            }
        }
示例#4
0
        public void LongPress(UILongPressGestureRecognizer touches)
        {
            if (touches.State == UIGestureRecognizerState.Ended)
            {
                CGPoint location = touches.LocationInView(_map);
                CLLocationCoordinate2D coordinate = _map.ConvertPoint(location, _map);

                _marcerRow           = new MapMarkerEntity();
                _marcerRow.Latitude  = coordinate.Latitude;
                _marcerRow.Longitude = coordinate.Longitude;

                ViewModel.SaveMarkerInList(_marcerRow);

                _map.AddAnnotations(new MKPointAnnotation()
                {
                    Title      = Constants.MapMarker,
                    Coordinate = new CLLocationCoordinate2D(coordinate.Latitude, coordinate.Longitude)
                });
            }
        }
示例#5
0
        public void OnMapReady(GoogleMap googleMap)
        {
            _map = googleMap;
            _map.UiSettings.CompassEnabled          = false;
            _map.UiSettings.MyLocationButtonEnabled = true;
            _map.UiSettings.MapToolbarEnabled       = true;
            _map.MyLocationEnabled = true;

            var myLocation = new MapMarkerEntity();

            Position getPosition = GetCurrentPosition().Result;

            var builder = new LatLngBounds.Builder();

            myLocation.Latitude  = getPosition.Latitude;
            myLocation.Longitude = getPosition.Longitude;
            builder.Include(new LatLng(myLocation.Latitude, myLocation.Longitude));

            _map.AddMarker(new MarkerOptions().SetPosition(new LatLng(myLocation.Latitude, myLocation.Longitude)).SetTitle($"{ViewModel.TaskId}")
                           .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen)));

            if (ViewModel.MarkerList != null && ViewModel.MarkerList.Any())
            {
                foreach (MapMarkerEntity coord in ViewModel.MarkerList)
                {
                    _map.AddMarker(new MarkerOptions().SetPosition(new LatLng(coord.Latitude, coord.Longitude))
                                   .SetTitle($"{ViewModel.TaskId}"));

                    builder.Include(new LatLng(coord.Latitude, coord.Longitude));
                }
            }

            LatLngBounds bound = builder.Build();

            _map.MoveCamera(CameraUpdateFactory.NewLatLngBounds(bound, Constants.MapPadding));

            _map.MapClick += ClickOnMap;
        }
示例#6
0
        public void SaveMarkerInList(MapMarkerEntity marker)
        {
            marker.TaskId = TaskId;

            MarkerList.Add(marker);
        }
示例#7
0
 public void InsertMarker(MapMarkerEntity marker)
 {
     _markersRepository.Insert(marker);
 }