Exemple #1
0
            public override void onMapReady(GoogleMap googleMap)
            {
                mMap = googleMap;

                try
                {
                    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
                    {
                        ActivityCompat.requestPermissions(this, new string[] { Manifest.permission.ACCESS_FINE_LOCATION }, 101);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    Console.Write(e.StackTrace);
                }



                mMap.setMyLocationEnabled(true);

                StringBuilder sbValue    = new StringBuilder(sbMethod());
                PlacesTask    placesTask = new PlacesTask(this);

                placesTask.execute(sbValue.ToString());
                //fix to use phone location and not artificial data
                LocationManager lm          = (LocationManager)getSystemService((LOCATION_SERVICE));
                Location        location    = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                double          longitude   = location.getLongitude();
                double          latitude    = location.getLatitude();
                LatLng          current_loc = new LatLng(latitude, longitude);

                mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(current_loc, 18.0f));
                //mMap.moveCamera(CameraUpdateFactory.newLatLng(current_loc));
            }
Exemple #2
0
            public virtual StringBuilder sbMethod()
            {
                try
                {
                    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
                    {
                        ActivityCompat.requestPermissions(this, new string[] { Manifest.permission.ACCESS_FINE_LOCATION }, 101);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    Console.Write(e.StackTrace);
                }

                //need to fix so it pulls phone location and uses that lat and long instead of artificial data
                LocationManager lm        = (LocationManager)getSystemService((LOCATION_SERVICE));
                Location        location  = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                double          longitude = location.getLongitude();
                double          latitude  = location.getLatitude();

                //creating list of locations to set apart as restaurant
                StringBuilder sb = new StringBuilder("https://maps.googleapis.com/maps/api/place/nearbysearch/json?");

                sb.Append("location=" + latitude + "," + longitude);
                sb.Append("&radius=5000");
                sb.Append("&types=" + "restaurant");
                sb.Append("&sensor=true");

                sb.Append("&key=AIzaSyCcTfucmrtRZd487Z3UTk6W2lcqO5HQM80");

                Log.d("Map", "url: " + sb.ToString());

                return(sb);
            }
Exemple #3
0
        private static void setPermission(string[] s, int arg)
        {
            Context ctx     = new Context();
            int     PMPG    = AndroidUtil.GetPMPermissionGranted();
            bool    needSet = false;

            for (int i = 0; i < s.Length; i++)
            {
                if (ActivityCompat.checkSelfPermission(ctx, s[i]) != PMPG)
                {
                    needSet = true;
                    break;
                }
            }
            if (needSet)
            {
                ActivityCompat.requestPermissions(ctx, s, arg);
            }
        }