예제 #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));
            }