コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.mountainMap);
            //settings database getting records
            InitializeLocationManager();
            DBItineraryRepository dbr = new DBItineraryRepository();

            var terrain        = "terrain";
            var terrainValue   = "1";
            var normal         = "normal";
            var normalValue    = "0";
            var satellite      = "satellite";
            var satelliteValue = "0";
            var hybrid         = "toiletries";
            var hybridValue    = "0";

            try
            {
                var terrainResult = dbr.GetRecordSettings(terrain);
                terrainValue = terrainResult;
                var normalResult = dbr.GetRecordSettings(normal);
                normalValue = normalResult;
                var satelliteResult = dbr.GetRecordSettings(satellite);
                satelliteValue = satelliteResult;
                var hybridResult = dbr.GetRecordSettings(hybrid);
                hybridValue = hybridResult;
            }
            catch (Exception ex)
            {
            }

            MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map);
            GoogleMap   map     = mapFrag.Map;

            map.SetOnInfoWindowClickListener(this);

            // position
            LatLng locations = new LatLng(13, 122);

            CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
            builder.Target(locations);
            builder.Zoom(6);
            CameraPosition cameraPosition = builder.Build();
            CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);

            if (map != null)
            {
                map.Clear();
                map.MapType = GoogleMap.MapTypeTerrain;

                if (terrainValue == "1")
                {
                    map.MapType = GoogleMap.MapTypeTerrain;
                }
                else if (normalValue == "1")
                {
                    map.MapType = GoogleMap.MapTypeNormal;
                }
                else if (satelliteValue == "1")
                {
                    map.MapType = GoogleMap.MapTypeSatellite;
                }
                else if (hybridValue == "1")
                {
                    map.MapType = GoogleMap.MapTypeHybrid;
                }

                map.UiSettings.ZoomControlsEnabled = true;
                map.UiSettings.CompassEnabled      = true;
                map.MoveCamera(cameraUpdate);

                mountainsRepository = new MountainsService();
                mMountains          = mountainsRepository.GetAllMountains();

                foreach (Mountain item in mMountains)
                {
                    marker = map.AddMarker(new MarkerOptions()
                                           .SetPosition(new LatLng(item.Lat, item.Lng))
                                           .SetTitle(item.MtName)
                                           .SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueYellow)));
                }
            }
        }
コード例 #2
0
ファイル: SettingsAct.cs プロジェクト: mjqanda/ap
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.settingsLayout);

            // Create your application here
            DBItineraryRepository dbr = new DBItineraryRepository();

            var terrain        = "terrain";
            var terrainValue   = "1";
            var normal         = "normal";
            var normalValue    = "0";
            var satellite      = "satellite";
            var satelliteValue = "0";
            var hybrid         = "toiletries";
            var hybridValue    = "0";

            RadioButton rbTerrain    = FindViewById <RadioButton>(Resource.Id.rbTerrain);
            RadioButton rbNormal     = FindViewById <RadioButton>(Resource.Id.rbNormal);
            RadioButton rbSatellite  = FindViewById <RadioButton>(Resource.Id.rbSatellite);
            RadioButton rbHybrid     = FindViewById <RadioButton>(Resource.Id.rbHybrid);
            Button      aboutbuttonn = FindViewById <Button>(Resource.Id.btnAbout);

            aboutbuttonn.Click += Aboutbuttonn_Click;
            try
            {
                var terrainResult = dbr.GetRecordSettings(terrain);
                terrainValue = terrainResult;
                var normalResult = dbr.GetRecordSettings(normal);
                normalValue = normalResult;
                var satelliteResult = dbr.GetRecordSettings(satellite);
                satelliteValue = satelliteResult;
                var hybridResult = dbr.GetRecordSettings(hybrid);
                hybridValue = hybridResult;
            }
            catch (Exception ex)
            {
            }

            //implementing the value
            if (terrainValue == "1")
            {
                rbTerrain.Checked   = true;
                rbNormal.Checked    = false;
                rbSatellite.Checked = false;
                rbHybrid.Checked    = false;
            }
            else if (normalValue == "1")
            {
                rbNormal.Checked = true;
            }
            else if (satelliteValue == "1")
            {
                rbSatellite.Checked = true;
            }
            else if (hybridValue == "1")
            {
                rbHybrid.Checked = true;
            }


            //saving
            Button btnSave = FindViewById <Button>(Resource.Id.btnSave);

            btnSave.Click += (sender, e) =>
            {
                if (rbTerrain.Checked == true)
                {
                    terrainValue   = "1";
                    normalValue    = "0";
                    hybridValue    = "0";
                    satelliteValue = "0";
                }
                else if (rbNormal.Checked == true)
                {
                    terrainValue   = "0";
                    normalValue    = "1";
                    hybridValue    = "0";
                    satelliteValue = "0";
                }
                else if (rbSatellite.Checked == true)
                {
                    terrainValue   = "0";
                    normalValue    = "0";
                    hybridValue    = "0";
                    satelliteValue = "1";
                }
                else if (rbHybrid.Checked == true)
                {
                    terrainValue   = "0";
                    normalValue    = "0";
                    hybridValue    = "1";
                    satelliteValue = "0";
                }


                var result = dbr.InsertRecordSettings(terrain, terrainValue);
                dbr.InsertRecordSettings(normal, normalValue);
                dbr.InsertRecordSettings(satellite, satelliteValue);
                dbr.InsertRecordSettings(hybrid, hybridValue);

                Toast.MakeText(this, result, ToastLength.Short).Show();

                Finish();
            };
        }