예제 #1
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);
        }
예제 #2
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;
        }
예제 #3
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();
                });
            });
        }
예제 #4
0
        /// <summary>
        /// Enabling my location and setting active assignment
        /// </summary>
        protected override void OnResume()
        {
            base.OnResume();

            UpdateLocations();
            myLocation.EnableMyLocation();
            var tabActivity = (AssignmentTabActivity)Parent;

            AssignmentTabActivity.MapDataWrapper mapDataWrapper = null;
            if (tabActivity != null)
            {
                mapDataWrapper = tabActivity.MapData;
            }

            if (mapDataWrapper != null)
            {
                mapView.Controller.SetZoom(mapDataWrapper.Zoom);
                mapView.Controller.AnimateTo(mapDataWrapper.OverlayPoint);
                mapView.AddView(mapDataWrapper.OverlayBubble);
            }
            else
            {
                myLocation.RunOnFirstFix(() => {
                    mapView.Controller.AnimateTo(myLocation.MyLocation);
                });
                mapView.Controller.SetZoom(5);
            }

            if (assignmentViewModel.ActiveAssignment != null)
            {
                SetAssignment(true);
            }
            else
            {
                SetAssignment(false);
            }

            var dialog = new AlertDialog.Builder(this)
                         .SetTitle("Google Maps")
                         .SetMessage(Resources.GetString(Resource.String.GoogleMapsKeyIssue))
                         .SetPositiveButton("Ok", (sender, e) => { })
                         .Show();
        }
예제 #5
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();
                });
            });
        }