Esempio n. 1
0
        /// <summary>
        ///     Adds all markers of the current ExhibitSet to the specified map.
        /// </summary>
        /// <param name="mapView">MapView where the markers should be displayed.</param>
        private void SetAllMarkers(MapView mapView)
        {
            LocationOverlay   = new MyLocationOverlay(Activity, mapView);
            MyScaleBarOverlay = new ScaleBarOverlay(Activity);

            var markerInfoWindow = new ViaPointInfoWindow(Resource.Layout.navigation_info_window, mapView, Activity);
            var mapMarkerIcon    = ContextCompat.GetDrawable(Activity, Resource.Drawable.marker_blue);
            var setMarker        = new SetMarker(mapView, markerInfoWindow);


            foreach (var e in ExhibitSet.ActiveSet)
            {
                //One Marker Object
                var geoPoint = new GeoPoint(e.Location.Latitude, e.Location.Longitude);
                var marker   = setMarker.AddMarker(null, e.Name, e.Description, geoPoint, mapMarkerIcon, e.Id);
                mapView.OverlayManager.Add(marker);
            }


            userPosition = new Marker(mapView);
            userPosition.SetIcon(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.ic_my_location, null));
            userPosition.Position = new GeoPoint(GeoLocation.Latitude, GeoLocation.Longitude);
            userPosition.SetInfoWindow(null);
            mapView.OverlayManager.Add(userPosition);

            mapView.OverlayManager.Add(MyScaleBarOverlay);
            mapView.OverlayManager.Add(LocationOverlay);
            mapView.Invalidate();
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.MapFragmentLayout);

            mapView    = FindViewById <MapView> (Resource.Id.fragmentMapView);
            myLocation = new MyLocationOverlay(this, mapView);
            myLocation.RunOnFirstFix(() => {
                //mapView.Controller.AnimateTo (myLocation.MyLocation);

                var maxLat  = Math.Max(myLocation.MyLocation.LatitudeE6, assignment.Latitude.ToIntE6());
                var minLat  = Math.Min(myLocation.MyLocation.LatitudeE6, assignment.Latitude.ToIntE6());
                var maxLong = Math.Max(myLocation.MyLocation.LongitudeE6, assignment.Longitude.ToIntE6());
                var minLong = Math.Min(myLocation.MyLocation.LongitudeE6, assignment.Longitude.ToIntE6());

                mapView.Controller.ZoomToSpan(Math.Abs(maxLat - minLat), Math.Abs(maxLong - minLong));

                mapView.Controller.AnimateTo(new GeoPoint((maxLat + minLat) / 2, (maxLong + minLong) / 2));
            });

            mapView.Overlays.Add(myLocation);
            mapView.Controller.SetZoom(5);
            mapView.Clickable = true;
            mapView.Enabled   = true;
            mapView.SetBuiltInZoomControls(true);
        }
Esempio n. 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            MapView mMapView = FindViewById <MapView>(Resource.Id.bmapsView);

            App.Current.Map.CallBack.ReceiveLocation = (location) =>
            {
                MapController mMapController = mMapView.Controller;
                // 得到mMapView的控制权,可以用它控制和驱动平移和缩放
                GeoPoint point = new GeoPoint((int)(location.Latitude * 1E6), (int)(location.Longitude * 1E6));
                //用给定的经纬度构造一个GeoPoint,单位是微度 (度 * 1E6)
                mMapController.SetCenter(point); //设置地图中心点
                mMapController.SetZoom(18);      //设置地图zoom级别
                MyLocationOverlay overlay = new MyLocationOverlay(mMapView);
                overlay.SetData(new LocationData()
                {
                    Latitude = location.Latitude, Longitude = location.Longitude, Direction = 2.0f
                });
                mMapView.Overlays.Add(overlay);
                mMapView.Refresh();
                mMapView.Controller.AnimateTo(point);
                //PanoramaView
            };
        }
Esempio n. 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Get a reference to the sensor manager
            sensor_manager = (SensorManager)GetSystemService(Context.SensorService);

            // Create our view
            var map_view = new MapView(this, "MapViewCompassDemo_DummyAPIKey");

            rotate_view = new RotateView(this);
            rotate_view.AddView(map_view);

            SetContentView(rotate_view);

            // Create the location overlay
            location_overlay = new MyLocationOverlay(this, map_view);
            location_overlay.RunOnFirstFix(delegate {
                map_view.Controller.AnimateTo(location_overlay.MyLocation);
            });
            map_view.Overlays.Add(location_overlay);

            map_view.Controller.SetZoom(18);
            map_view.Clickable = true;
            map_view.Enabled   = true;
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            /*
             * For Information on how to add you own keystore to the project read the README from the
             * old GoogleMaps sample: https://github.com/xamarin/monodroid-samples/tree/master/GoogleMaps
             *
             * */

            // Remember to generate your own API key
            mapView = new MapView(this, "0Nd7w_yOI1NbUsBP_Mg2IosWa0Ns2j22r4meJnA");
            mapView.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);

            SetContentView(mapView);

            mapView.SetBuiltInZoomControls(true);
            mapView.Enabled   = true;
            mapView.Clickable = true;                                 //This has to be set to true to be able to navigate the map

            myLocationOverlay = new MyLocationOverlay(this, mapView); //this shows your current position on the map
            mapView.Overlays.Add(myLocationOverlay);

            Drawable marker = Resources.GetDrawable(Resource.Drawable.Icon); //these are the markers put on the map

            myItemizedOverlay = new MyItemizedOverlay(this, marker);
            mapView.Overlays.Add(myItemizedOverlay);

            myItemizedOverlay.AddItem(new GeoPoint((int)(55.816149 * 1E6), (int)(12.532868 * 1E6)), "BKSV", "Brüel & Kjær Sound & Vision");
            mapView.PostInvalidate();
        }
Esempio n. 6
0
        //Here all Markers for the Exhibits in the Main Map are set
        //and some general stuff
        private void SetMainScreenMarkers(IReadOnlyList <Exhibit> set)
        {
            locationOverlay = new MyLocationOverlay(activity, mapView);
            var compassOverlay = new CompassOverlay(activity, mapView);

            compassOverlay.EnableCompass();
            mapView.OverlayManager.Add(locationOverlay);
            mapView.OverlayManager.Add(compassOverlay);

            //Here all exhibit markers and bubbles are set if the Exhibit is not null
            if (set != null)
            {
                var markerInfoWindow = new ViaPointInfoWindow(Resource.Layout.navigation_info_window, mapView);
                var mapMarkerIcon    = ContextCompat.GetDrawable(activity, Resource.Drawable.marker_blue);
                var setMarker        = new SetMarker(mapView, markerInfoWindow);

                foreach (var e in set)
                {
                    //One Marker Object
                    var geoPoint = new GeoPoint(e.Location.Latitude, e.Location.Longitude);
                    var marker   = setMarker.AddMarker(null, e.Name, e.Description, geoPoint, mapMarkerIcon, e.Id);
                    mapView.OverlayManager.Add(marker);
                }
            }

            mapView.Invalidate();
        }
Esempio n. 7
0
        void AddMyLocationOverlay(MapView map)
        {
            _myLocationOverlay = new MyLocationOverlay(this, map);
            map.Overlays.Add(_myLocationOverlay);

            _myLocationOverlay.RunOnFirstFix(() => {
                map.Controller.AnimateTo(_myLocationOverlay.MyLocation);

                RunOnUiThread(() => {
                    var toast = Toast.MakeText(this, "Located", ToastLength.Short);
                    toast.Show();
                });
            });
        }
Esempio n. 8
0
        void AddMyLocationOverlay(MapView map)
        {
            myLocationOverlay = new MyLocationOverlay(this, map);
            map.Overlays.Add(myLocationOverlay);

            myLocationOverlay.RunOnFirstFix(() => {
                map.Controller.AnimateTo(myLocationOverlay.MyLocation);

                RunOnUiThread(() => {
                    var toast = Toast.MakeText(this, "Located", ToastLength.Short);
                    toast.Show();
                });
            });
        }
Esempio n. 9
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create your application here
            SetContentView(Resource.Layout.MapViewLayout);

            assignmentMapViewLayout        = FindViewById <LinearLayout> (Resource.Id.mapViewAssignmentLayout);
            assignmentMapViewLayout.Click += (sender, e) => {
                var intent      = new Intent(this, typeof(SummaryActivity));
                var tabActivity = (AssignmentTabActivity)Parent;
                tabActivity.MapData = null;
                assignmentViewModel.SelectedAssignment = assignmentViewModel.ActiveAssignment;
                menuViewModel.MenuIndex = Constants.Navigation.IndexOf("Map");
                StartActivity(intent);
            };
            mapView = FindViewById <MapView> (Resource.Id.googleMapsView);

            myLocation = new MyLocationOverlay(this, mapView);

            mapView.Overlays.Add(myLocation);
            mapView.Clickable = true;
            mapView.Enabled   = true;
            mapView.SetBuiltInZoomControls(true);


            //View containing the active assignment
            var            view     = new View(this);
            LayoutInflater inflator = (LayoutInflater)GetSystemService(Context.LayoutInflaterService);

            view = inflator.Inflate(Resource.Layout.AssignmentItemLayout, null);
            assignmentMapViewLayout.AddView(view);
            view.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);
            view.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.active_assignment_selector));
            number        = view.FindViewById <TextView> (Resource.Id.assignmentItemNumber);
            job           = view.FindViewById <TextView> (Resource.Id.assignmentJob);
            name          = view.FindViewById <TextView> (Resource.Id.assignmentName);
            phone         = view.FindViewById <TextView> (Resource.Id.assignmentPhone);
            address       = view.FindViewById <TextView> (Resource.Id.assignmentAddress);
            buttonLayout  = view.FindViewById <LinearLayout> (Resource.Id.assignmentButtonLayout);
            timerLayout   = view.FindViewById <LinearLayout> (Resource.Id.assignmentTimerLayout);
            activeSpinner = view.FindViewById <Spinner> (Resource.Id.assignmentStatus);
            spinnerImage  = view.FindViewById <ImageView> (Resource.Id.assignmentStatusImage);
            timer         = view.FindViewById <ToggleButton> (Resource.Id.assignmentTimer);
            timerText     = view.FindViewById <TextView> (Resource.Id.assignmentTimerText);
            phoneButton   = view.FindViewById <RelativeLayout> (Resource.Id.assignmentPhoneLayout);
            mapButton     = view.FindViewById <RelativeLayout> (Resource.Id.assignmentAddressLayout);

            phoneButton.Click += (sender, e) => {
                Extensions.MakePhoneCall(this, phone.Text);
            };

            mapButton.Click += (sender, e) => {
                var intent      = new Intent(this, typeof(SummaryActivity));
                var tabActivity = (AssignmentTabActivity)Parent;
                tabActivity.MapData = null;
                assignmentViewModel.SelectedAssignment = assignmentViewModel.ActiveAssignment;
                menuViewModel.MenuIndex = 0;
                StartActivity(intent);
            };

            assignmentViewModel.LoadTimerEntryAsync().ContinueWith(_ => {
                RunOnUiThread(() => {
                    if (assignmentViewModel.Recording)
                    {
                        timer.Checked = true;
                    }
                    else
                    {
                        timer.Checked = false;
                    }
                });
            });

            timer.CheckedChange += (sender, e) => {
                if (e.IsChecked != assignmentViewModel.Recording)
                {
                    if (assignmentViewModel.Recording)
                    {
                        assignmentViewModel.PauseAsync();
                    }
                    else
                    {
                        assignmentViewModel.RecordAsync();
                    }
                }
            };

            activeSpinner.ItemSelected += (sender, e) => {
                if (assignment != null)
                {
                    var selected = assignmentViewModel.AvailableStatuses.ElementAtOrDefault(e.Position);
                    if (selected != assignment.Status)
                    {
                        switch (selected)
                        {
                        case AssignmentStatus.Hold:
                            assignment.Status = selected;
                            assignmentViewModel.SaveAssignmentAsync(assignment).ContinueWith(_ => {
                                RunOnUiThread(() => {
                                    SetAssignment(false);
                                    mapView.Overlays.Clear();
                                    mapView.Overlays.Add(myLocation);
                                    UpdateLocations();
                                });
                            });
                            break;

                        case AssignmentStatus.Complete:
                            //go to confirmations
                            var intent = new Intent(this, typeof(SummaryActivity));
                            menuViewModel.MenuIndex = Constants.Navigation.IndexOf(Constants.Confirmations);
                            StartActivity(intent);
                            break;

                        default:
                            break;
                        }
                    }
                }
            };
        }