public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			mapView = base.OnCreateView (inflater, container, savedInstanceState);

			// Save ScreenController for later use
			ctrl = ((GameController)this.Activity);

			RelativeLayout view = new RelativeLayout(ctrl);
			view.AddView(mapView, new RelativeLayout.LayoutParams(-1, -1));

//			var view = inflater.Inflate(Resource.Layout.ScreenMap, container, false);
//
//			mapView = new MapView(ctrl);
//			mapView.OnCreate(savedInstanceState);
//
			// Set all relevant data for map

			_zoom = (float)Main.Prefs.GetDouble("MapZoom", 16);

			_map = this.Map;
			_map.MapType = GoogleMap.MapTypeNormal;
			_map.MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(Main.GPS.Location.Latitude, Main.GPS.Location.Longitude), _zoom));
			_map.MyLocationEnabled = true;
			_map.BuildingsEnabled = true;
			_map.UiSettings.ZoomControlsEnabled = false;
			_map.UiSettings.MyLocationButtonEnabled = false;
			_map.UiSettings.CompassEnabled = false;
			_map.UiSettings.TiltGesturesEnabled = false;
			_map.UiSettings.RotateGesturesEnabled = false;
			_map.MapClick += OnMapClick;

			// Create tile layers
			_osmTileLayer = new OsmTileProvider("http://a.tile.openstreetmap.org/{0}/{1}/{2}.png");
			_ocmTileLayer = new OsmTileProvider("http://c.tile.opencyclemap.org/cycle/{0}/{1}/{2}.png");

			// Set selected map type
			SetMapType(Main.Prefs.GetInt("map_source", 0));

			// Create the zones the first time
			CreateZones();

			// Create layout for map buttons
			layoutButtons = new RelativeLayout(ctrl);

			// Button for center menu
			var lp = new RelativeLayout.LayoutParams(64, 64);
			lp.SetMargins(16, 16, 16, 8);
			lp.AddRule(LayoutRules.AlignParentLeft);
			lp.AddRule(LayoutRules.AlignParentTop);

			btnMapCenter = new ImageButton(ctrl);
			btnMapCenter.Id = 1;
			btnMapCenter.SetImageResource(Resource.Drawable.ic_button_center);
			btnMapCenter.SetBackgroundResource(Resource.Drawable.MapButton);
			btnMapCenter.Click += OnMapCenterButtonClick;

			layoutButtons.AddView(btnMapCenter, lp);

			// Button for the orientation: north up or always in direction
			lp = new RelativeLayout.LayoutParams(64, 64);
			lp.SetMargins(16, 8, 16, 16);
			lp.AddRule(LayoutRules.Below, btnMapCenter.Id);
			lp.AddRule(LayoutRules.AlignParentLeft);

			btnMapOrientation = new ImageButton(ctrl);
			if (Main.Prefs.GetBool ("MapOrientationNorth", true))
				btnMapOrientation.SetImageResource (Resource.Drawable.ic_button_orientation_north);
			else
				btnMapOrientation.SetImageResource (Resource.Drawable.ic_button_orientation);
			btnMapOrientation.SetBackgroundResource(Resource.Drawable.MapButton);
			btnMapOrientation.Click += OnMapOrientationButtonClick;

			layoutButtons.AddView(btnMapOrientation, lp);

			// Button for selecting the map type
			lp = new RelativeLayout.LayoutParams(64, 64);
			lp.SetMargins(16, 16, 16, 8);
			lp.AddRule(LayoutRules.AlignParentTop);
			lp.AddRule(LayoutRules.AlignParentRight);

			btnMapType = new ImageButton(ctrl);
			btnMapType.SetImageResource(Resource.Drawable.ic_button_layer);
			btnMapType.SetBackgroundResource(Resource.Drawable.MapButton);
			btnMapType.Click += OnMapTypeButtonClick;

			layoutButtons.AddView(btnMapType, lp);

			view.AddView(layoutButtons);

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

            // Save ScreenController for later use
            ctrl = ((GameController)this.Activity);

            RelativeLayout view = new RelativeLayout(ctrl);

            view.AddView(mapView, new RelativeLayout.LayoutParams(-1, -1));

//			var view = inflater.Inflate(Resource.Layout.ScreenMap, container, false);
//
//			mapView = new MapView(ctrl);
//			mapView.OnCreate(savedInstanceState);
//
            // Set all relevant data for map

            _zoom = (float)Main.Prefs.GetDouble("MapZoom", 16);

            _map         = this.Map;
            _map.MapType = GoogleMap.MapTypeNormal;
            _map.MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(Main.GPS.Location.Latitude, Main.GPS.Location.Longitude), _zoom));
            _map.MyLocationEnabled = true;
            _map.BuildingsEnabled  = true;
            _map.UiSettings.ZoomControlsEnabled     = false;
            _map.UiSettings.MyLocationButtonEnabled = false;
            _map.UiSettings.CompassEnabled          = false;
            _map.UiSettings.TiltGesturesEnabled     = false;
            _map.UiSettings.RotateGesturesEnabled   = false;
            _map.MapClick += OnMapClick;

            // Create tile layers
            _osmTileLayer = new OsmTileProvider("http://a.tile.openstreetmap.org/{0}/{1}/{2}.png");
            _ocmTileLayer = new OsmTileProvider("http://c.tile.opencyclemap.org/cycle/{0}/{1}/{2}.png");

            // Set selected map type
            SetMapType(Main.Prefs.GetInt("map_source", 0));

            // Create the zones the first time
            CreateZones();

            // Create layout for map buttons
            layoutButtons = new RelativeLayout(ctrl);

            // Button for center menu
            var lp = new RelativeLayout.LayoutParams(64, 64);

            lp.SetMargins(16, 16, 16, 8);
            lp.AddRule(LayoutRules.AlignParentLeft);
            lp.AddRule(LayoutRules.AlignParentTop);

            btnMapCenter    = new ImageButton(ctrl);
            btnMapCenter.Id = 1;
            btnMapCenter.SetImageResource(Resource.Drawable.ic_button_center);
            btnMapCenter.SetBackgroundResource(Resource.Drawable.MapButton);
            btnMapCenter.Click += OnMapCenterButtonClick;

            layoutButtons.AddView(btnMapCenter, lp);

            // Button for the orientation: north up or always in direction
            lp = new RelativeLayout.LayoutParams(64, 64);
            lp.SetMargins(16, 8, 16, 16);
            lp.AddRule(LayoutRules.Below, btnMapCenter.Id);
            lp.AddRule(LayoutRules.AlignParentLeft);

            btnMapOrientation = new ImageButton(ctrl);
            if (Main.Prefs.GetBool("MapOrientationNorth", true))
            {
                btnMapOrientation.SetImageResource(Resource.Drawable.ic_button_orientation_north);
            }
            else
            {
                btnMapOrientation.SetImageResource(Resource.Drawable.ic_button_orientation);
            }
            btnMapOrientation.SetBackgroundResource(Resource.Drawable.MapButton);
            btnMapOrientation.Click += OnMapOrientationButtonClick;

            layoutButtons.AddView(btnMapOrientation, lp);

            // Button for selecting the map type
            lp = new RelativeLayout.LayoutParams(64, 64);
            lp.SetMargins(16, 16, 16, 8);
            lp.AddRule(LayoutRules.AlignParentTop);
            lp.AddRule(LayoutRules.AlignParentRight);

            btnMapType = new ImageButton(ctrl);
            btnMapType.SetImageResource(Resource.Drawable.ic_button_layer);
            btnMapType.SetBackgroundResource(Resource.Drawable.MapButton);
            btnMapType.Click += OnMapTypeButtonClick;

            layoutButtons.AddView(btnMapType, lp);

            view.AddView(layoutButtons);

            return(view);
        }