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();
        }
Ejemplo n.º 3
0
        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);
        }
 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 ();
         });
     });
 }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            locationManager = GetSystemService (Context.LocationService) as LocationManager;

            RequestWindowFeature (WindowFeatures.NoTitle);

            SetContentView (Resource.Layout.Map);

            var map = FindViewById<MapView>(Resource.Id.map);
            map.Clickable = true;
            map.Traffic = true;
            map.SetBuiltInZoomControls (true);

            myLocationOverlay = new MyLocationOverlay (this, map);
            map.Overlays.Add (myLocationOverlay);

            myLocationOverlay.RunOnFirstFix (() => {
                map.Controller.SetZoom (15);
                map.Controller.AnimateTo (myLocationOverlay.MyLocation);
            });
        }
Ejemplo n.º 6
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;
                        }
                    }
                }
            };
        }
Ejemplo n.º 7
0
 private void AddMyLocationOverlay()
 {
     _myLocationOverlay = new MyLocationOverlay(Activity, _map);
     _myLocationOverlay.RunOnFirstFix(() => _map.Controller.AnimateTo(_myLocationOverlay.MyLocation));
     _map.Overlays.Add(_myLocationOverlay);
 }