com.google.android.gms.maps.GoogleMap Java Examples

The following examples show how to use com.google.android.gms.maps.GoogleMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RunActivity.java    From SEAL-Demo with MIT License 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    MapUtil.changeMapStyle(TAG, mMap, this);
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(UPDATE_TIME);
    mLocationRequest.setFastestInterval(UPDATE_TIME);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (ContextCompat.checkSelfPermission(this,
                Manifest.permission.ACCESS_FINE_LOCATION)
                == PackageManager.PERMISSION_GRANTED) {
            //Location Permission already granted
            mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.myLooper());
            mMap.setMyLocationEnabled(true);
        }
    } else {
        mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.myLooper());
        mMap.setMyLocationEnabled(true);
    }
}
 
Example #2
Source File: DriverMapActivity.java    From UberClone with MIT License 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
        if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED){

        }else{
            checkLocationPermission();
        }
    }
}
 
Example #3
Source File: MapFragment.java    From droidkaigi2016 with Apache License 2.0 6 votes vote down vote up
@NeedsPermission(Manifest.permission.ACCESS_FINE_LOCATION)
void initGoogleMap() {
    SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);

    mapFragment.getMapAsync(googleMap -> {
        //noinspection MissingPermission
        googleMap.setMyLocationEnabled(true);
        binding.mapSearchView.bindData(placeMapList, placeMap -> {
            LatLng latLng = new LatLng(placeMap.latitude, placeMap.longitude);
            int duration = getResources().getInteger(R.integer.map_camera_move_mills);
            googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng), duration, null);
            Marker marker = markers.get(placeMap.nameRes);
            if (marker != null) marker.showInfoWindow();
        });

        binding.loadingView.setVisibility(View.GONE);
        googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        googleMap.setIndoorEnabled(true);
        googleMap.setBuildingsEnabled(true);
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LAT_LNG_CENTER, DEFAULT_ZOOM));
        UiSettings mapUiSettings = googleMap.getUiSettings();
        mapUiSettings.setCompassEnabled(true);
        renderMarkers(placeMapList, googleMap);
    });
}
 
Example #4
Source File: MapViewPager.java    From MapViewPager with Apache License 2.0 6 votes vote down vote up
private GoogleMap.OnMarkerClickListener createMarkerClickListenerSingle(final Adapter adapter) {
    return new GoogleMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            for (int i = 0; i < adapter.getCount(); i++) {
                CameraPosition cp = adapter.getCameraPosition(i);
                if (cp != null && cp.target != null
                        && cp.target.latitude == marker.getPosition().latitude
                        && cp.target.longitude == marker.getPosition().longitude) {
                    viewPager.setCurrentItem(i);
                    marker.showInfoWindow();
                    return true;
                }
            }
            return false;
        }
    };
}
 
Example #5
Source File: MapsMarkerActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
/**
 * Manipulates the map when it's available.
 * The API invokes this callback when the map is ready to be used.
 * This is where we can add markers or lines, add listeners or move the camera. In this case,
 * we just add a marker near Sydney, Australia.
 * If Google Play services is not installed on the device, the user receives a prompt to install
 * Play services inside the SupportMapFragment. The API invokes this method after the user has
 * installed Google Play services and returned to the app.
 */
// [END_EXCLUDE]
// [START maps_marker_on_map_ready_add_marker]
@Override
public void onMapReady(GoogleMap googleMap) {
    // [START_EXCLUDE silent]
    // Add a marker in Sydney, Australia,
    // and move the map's camera to the same location.
    // [END_EXCLUDE]
    LatLng sydney = new LatLng(-33.852, 151.211);
    googleMap.addMarker(new MarkerOptions()
        .position(sydney)
        .title("Marker in Sydney"));
    // [START_EXCLUDE silent]
    googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
    // [END_EXCLUDE]
}
 
Example #6
Source File: HeatmapsPlacesDemoActivity.java    From android-maps-utils with Apache License 2.0 6 votes vote down vote up
@Override
protected void startDemo(boolean isRestore) {
    EditText editText = findViewById(R.id.input_text);
    editText.setOnEditorActionListener((textView, actionId, keyEvent) -> {
        boolean handled = false;
        if (actionId == EditorInfo.IME_ACTION_GO) {
            submit(null);
            handled = true;
        }
        return handled;
    });

    mCheckboxLayout = findViewById(R.id.checkboxes);
    GoogleMap map = getMap();
    if (!isRestore) {
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY, 11));
    }
    // Add a circle around Sydney to roughly encompass the results
    map.addCircle(new CircleOptions()
            .center(SYDNEY)
            .radius(SEARCH_RADIUS * 1.2)
            .strokeColor(Color.RED)
            .strokeWidth(4));
}
 
Example #7
Source File: CameraDemoActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    map = googleMap;

    map.setOnCameraIdleListener(this);
    map.setOnCameraMoveStartedListener(this);
    map.setOnCameraMoveListener(this);
    map.setOnCameraMoveCanceledListener(this);
    // [START_EXCLUDE silent]
    // We will provide our own zoom controls.
    map.getUiSettings().setZoomControlsEnabled(false);
    map.getUiSettings().setMyLocationButtonEnabled(true);
    // [END_EXCLUDE]

    // Show Sydney
    map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-33.87365, 151.20689), 10));
}
 
Example #8
Source File: HomeFragment.java    From SEAL-Demo with MIT License 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(UPDATE_TIME);
    mLocationRequest.setFastestInterval(UPDATE_TIME);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (ActivityCompat.checkSelfPermission(myContext,
                Manifest.permission.ACCESS_FINE_LOCATION)
                == PackageManager.PERMISSION_GRANTED) {
            //Location Permission already granted
            mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.myLooper());
            mMap.setMyLocationEnabled(true);
        }
    } else {
        mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.myLooper());
        mMap.setMyLocationEnabled(true);
    }
}
 
Example #9
Source File: LocationPickerActivity.java    From LocationPicker with MIT License 6 votes vote down vote up
private void addMarker() {

        LatLng coordinate = new LatLng(mLatitude, mLongitude);
        if (mMap != null) {
            MarkerOptions markerOptions;
            try {
                mMap.clear();
                imgSearch.setText("" + userAddress);

                markerOptions = new MarkerOptions().position(coordinate).title(userAddress).icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_place_red_800_24dp));
                CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(coordinate, 14);
                mMap.animateCamera(cameraUpdate);
                mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);

                Marker marker = mMap.addMarker(markerOptions);
                marker.showInfoWindow();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }

    }
 
Example #10
Source File: FreightTrackGoogleMapFragment.java    From ESeal with Apache License 2.0 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    // Instantiates a new Polyline object and adds points to define a rectangle
    com.google.android.gms.maps.model.PolylineOptions rectOptions = new com.google.android.gms.maps.model.PolylineOptions()
            .add(new com.google.android.gms.maps.model.LatLng(-18.5186650000, 141.9748780000))
            .add(new com.google.android.gms.maps.model.LatLng(-18.5186650000, 144.9748780000))  // North of the previous point, but at the same longitude
            .add(new com.google.android.gms.maps.model.LatLng(-20.5186650000, 144.9748780000))  // Same latitude, and 30km to the west
            .add(new com.google.android.gms.maps.model.LatLng(-20.5186650000, 141.9748780000))  // Same longitude, and 16km to the south
            .add(new com.google.android.gms.maps.model.LatLng(-24.5186650000, 141.9748780000)); // Closes the polyline.

    rectOptions.width(8)
            .color(ContextCompat.getColor(getActivity(), R.color.red_500));

    // Get back the mutable Polyline
    com.google.android.gms.maps.model.Polyline polyline = googleMap.addPolyline(rectOptions);

    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new com.google.android.gms.maps.model.LatLng(-18.5186650000, 141.9748780000), 6));
}
 
Example #11
Source File: MainFragment.java    From AndroidSlidingUpPanel-foursquare-map-demo with Apache License 2.0 6 votes vote down vote up
private void setUpMapIfNeeded() {
    // Do a null check to confirm that we have not already instantiated the map.
    if (mMap == null) {
        // Try to obtain the map from the SupportMapFragment.
        mMap = mMapFragment.getMap();
        // Check if we were successful in obtaining the map.
        if (mMap != null) {
            mMap.setMyLocationEnabled(false);
            mMap.getUiSettings().setCompassEnabled(false);
            mMap.getUiSettings().setZoomControlsEnabled(false);
            mMap.getUiSettings().setMyLocationButtonEnabled(false);
            LatLng update = getLastKnownLocation();
            if (update != null) {
                mMap.moveCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.fromLatLngZoom(update, 11.0f)));
            }
            mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
                @Override
                public void onMapClick(LatLng latLng) {
                    mIsNeedLocationUpdate = false;
                    moveToLocation(latLng, false);
                }
            });
        }
    }
}
 
Example #12
Source File: GeoPackageTileTableCacheOverlay.java    From mage-android with Apache License 2.0 6 votes vote down vote up
@Override
public String onMapClick(LatLng latLng, MapView mapView, GoogleMap map) {
    StringBuilder message = new StringBuilder();

    for(FeatureOverlayQuery featureOverlayQuery: featureOverlayQueries){
        String overlayMessage = featureOverlayQuery.buildMapClickMessage(latLng, mapView, map);
        if(overlayMessage != null){
            if(message.length() > 0){
                message.append("\n\n");
            }
            message.append(overlayMessage);
        }
    }

    return message.length() > 0 ? message.toString() : null;
}
 
Example #13
Source File: RichLayer.java    From richmaps with Apache License 2.0 6 votes vote down vote up
private RichLayer(final View view, final GoogleMap map, final float zIndex,
                  final int paddingLeft, final int paddingTop,
                  final int paddingRight, final int paddingBottom) {
    if (view == null || map == null) {
        throw new IllegalArgumentException("View and GoogleMap cannot be null");
    }

    this.view = view;
    this.map = map;
    this.zIndex = zIndex;
    this.paddingLeft = paddingLeft;
    this.paddingTop = paddingTop;
    this.paddingRight = paddingRight;
    this.paddingBottom = paddingBottom;

    map.getUiSettings().setTiltGesturesEnabled(false); // For now, tilt gestures are not allowed when using RichLayer
}
 
Example #14
Source File: GoogleMapActivity.java    From coursera-android with MIT License 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap map) {
    if (map != null) {

        // Set the map position
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(29,
                -88), 3.0f));

        // Add a marker on Washington, DC, USA
        map.addMarker(new MarkerOptions().position(
                new LatLng(38.8895, -77.0352)).title(
                getString(R.string.in_washington_string)));

        // Add a marker on Mexico City, Mexico
        map.addMarker(new MarkerOptions().position(
                new LatLng(19.13, -99.4)).title(
                getString(R.string.in_mexico_string)));
    }

}
 
Example #15
Source File: VisibleRegionDemoActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap map) {
    mMap = map;

    // Move to a place with indoor (SFO airport).
    mMap.setPadding(currentLeft, currentTop, currentRight, currentBottom);
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(SFO, 18));
    // Add a marker to the Opera House.
    mMap.addMarker(new MarkerOptions().position(SOH).title("Sydney Opera House"));
    // Add a camera idle listener.
    mMap.setOnCameraIdleListener(new OnCameraIdleListener() {
        @Override
        public void onCameraIdle() {
            mMessageView.setText("CameraChangeListener: " + mMap.getCameraPosition());
        }
    });
}
 
Example #16
Source File: GglMap.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void switchMapStyle(int mapStyle) {
    if (!this.isInit) {
        return;
    }
    GoogleMap googleMap;
    GoogleMap googleMap2;
    if (mapStyle == Constants.X8_GENERAL_MAP_STYLE_NORMAL) {
        googleMap = this.googleMap;
        googleMap2 = this.googleMap;
        googleMap.setMapType(1);
    } else if (mapStyle == Constants.X8_GENERAL_MAP_STYLE_SATELLITE) {
        googleMap = this.googleMap;
        googleMap2 = this.googleMap;
        googleMap.setMapType(2);
    }
}
 
Example #17
Source File: ClusterManager.java    From android-maps-utils with Apache License 2.0 6 votes vote down vote up
/**
 * Might re-cluster.
 */
@Override
public void onCameraIdle() {
    if (mRenderer instanceof GoogleMap.OnCameraIdleListener) {
        ((GoogleMap.OnCameraIdleListener) mRenderer).onCameraIdle();
    }

    mAlgorithm.onCameraChange(mMap.getCameraPosition());

    // delegate clustering to the algorithm
    if (mAlgorithm.shouldReclusterOnMapMovement()) {
        cluster();

        // Don't re-compute clusters if the map has just been panned/tilted/rotated.
    } else if (mPreviousCameraPosition == null || mPreviousCameraPosition.zoom != mMap.getCameraPosition().zoom) {
        mPreviousCameraPosition = mMap.getCameraPosition();
        cluster();
    }
}
 
Example #18
Source File: UiSettingsDemoActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap map) {
    mMap = map;

    mUiSettings = mMap.getUiSettings();

    // Keep the UI Settings state in sync with the checkboxes.
    mUiSettings.setZoomControlsEnabled(isChecked(R.id.zoom_buttons_toggle));
    mUiSettings.setCompassEnabled(isChecked(R.id.compass_toggle));
    mUiSettings.setMyLocationButtonEnabled(isChecked(R.id.mylocationbutton_toggle));
    mMap.setMyLocationEnabled(isChecked(R.id.mylocationlayer_toggle));
    mUiSettings.setScrollGesturesEnabled(isChecked(R.id.scroll_toggle));
    mUiSettings.setZoomGesturesEnabled(isChecked(R.id.zoom_gestures_toggle));
    mUiSettings.setTiltGesturesEnabled(isChecked(R.id.tilt_toggle));
    mUiSettings.setRotateGesturesEnabled(isChecked(R.id.rotate_toggle));
}
 
Example #19
Source File: MapUtils.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * Build a lat lng bounding box using the click location, map view, map, and screen percentage tolerance.
 * The bounding box can be used to query for features that were clicked
 *
 * @param latLng                click location
 * @param view                  map view
 * @param map                   map
 * @param screenClickPercentage screen click percentage between 0.0 and 1.0 for how close a feature
 *                              on the screen must be to be included in a click query
 * @return lat lng bounding box
 */
public static LatLngBoundingBox buildClickLatLngBoundingBox(LatLng latLng, View view, GoogleMap map, float screenClickPercentage) {

    // Get the screen width and height a click occurs from a feature
    int width = (int) Math.round(view.getWidth() * screenClickPercentage);
    int height = (int) Math.round(view.getHeight() * screenClickPercentage);

    // Get the screen click location
    Projection projection = map.getProjection();
    android.graphics.Point clickLocation = projection.toScreenLocation(latLng);

    // Get the screen click locations in each width or height direction
    android.graphics.Point left = new android.graphics.Point(clickLocation);
    android.graphics.Point up = new android.graphics.Point(clickLocation);
    android.graphics.Point right = new android.graphics.Point(clickLocation);
    android.graphics.Point down = new android.graphics.Point(clickLocation);
    left.offset(-width, 0);
    up.offset(0, -height);
    right.offset(width, 0);
    down.offset(0, height);

    // Get the coordinates of the bounding box points
    LatLng leftCoordinate = projection.fromScreenLocation(left);
    LatLng upCoordinate = projection.fromScreenLocation(up);
    LatLng rightCoordinate = projection.fromScreenLocation(right);
    LatLng downCoordinate = projection.fromScreenLocation(down);

    LatLngBoundingBox latLngBoundingBox = new LatLngBoundingBox(leftCoordinate, upCoordinate, rightCoordinate, downCoordinate);

    return latLngBoundingBox;
}
 
Example #20
Source File: PPTGoogleMapManager.java    From react-native-maps with MIT License 5 votes vote down vote up
/**
 * Places the default red marker on the map at the required position.
 *
 * @param googleMap
 * @param latLng
 */
private void markerWithDefaultIcon(GoogleMap googleMap, LatLng latLng, String publicId)
{
    MarkerOptions options = new MarkerOptions();

    options.position(latLng);

    Marker marker = googleMap.addMarker(options);

    publicMarkerIds.put(marker.getId(), publicId);
}
 
Example #21
Source File: ObservationClusterCollection.java    From mage-android with Apache License 2.0 5 votes vote down vote up
public ObservationClusterCollection(Context context, GoogleMap map) {
    this.context = context;

    clusterManager = new ClusterManager<ObservationClusterItem>(context, map);
    clusterManager.setAlgorithm(new PreCachingAlgorithmDecorator<ObservationClusterItem>(new GridBasedAlgorithm<ObservationClusterItem>()));

    clusterManager.setOnClusterItemClickListener(this);
}
 
Example #22
Source File: ShareLocationActivity.java    From Track-My-Location with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mGoogleMap = googleMap;
    mGoogleMap.setOnMarkerClickListener(marker -> {
        mFollowMarker = true;
        return false;
    });
    mGoogleMap.setOnMapClickListener(latLng -> mFollowMarker = false);
    if (mViewModel.getLastCachedLocation() != null)
        onLocationUpdated(mViewModel.getLastCachedLocation());
}
 
Example #23
Source File: Maps.java    From aware with MIT License 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap map) {

    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    map.setMyLocationEnabled(true);
    map.setTrafficEnabled(false);
    map.setIndoorEnabled(false);
    map.setBuildingsEnabled(false);
    map.getUiSettings().setZoomControlsEnabled(true);


    final CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(21, 78));
    CameraUpdate zoom = CameraUpdateFactory.zoomTo(15);

    map.moveCamera(center);
    map.animateCamera(zoom);

    GPSTracker tracker = new GPSTracker(activity);
    if (!tracker.canGetLocation()) {
        tracker.showSettingsAlert();

    } else {
        latitude = tracker.getLatitude();
        longitude = tracker.getLongitude();
        LatLng coordinate = new LatLng(latitude, longitude);
        CameraUpdate yourLocation = CameraUpdateFactory.newLatLngZoom(coordinate, 5);
        map.animateCamera(yourLocation);

    }

    this.map = map;

}
 
Example #24
Source File: ShareTripPresenter.java    From live-app-android with MIT License 5 votes vote down vote up
public void subscribeTripUpdates(GoogleMap googleMap, String tripId) {
    if (hyperTrackMap == null) {
        GoogleMapAdapter mapAdapter = new GoogleMapAdapter(googleMap, MapUtils.getBuilder(context).build());
        hyperTrackMap = HyperTrackMap.getInstance(context, mapAdapter);
        hyperTrackMap.setMyLocationEnabled(false);
    }

    state.setCurrentTripId(tripId);
    hyperTrackViews.subscribeToDeviceUpdates(hyperTrack.getDeviceID(), tripId, this);
    hyperTrackMap.bind(hyperTrackViews, hyperTrack.getDeviceID())
            .subscribeTrip(tripId);
}
 
Example #25
Source File: DefaultClusterRenderer.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
public DefaultClusterRenderer(Context context, GoogleMap map, ClusterManager<T> clusterManager) {
    mMap = map;
    mAnimate = true;
    mDensity = context.getResources().getDisplayMetrics().density;
    mIconGenerator = new IconGenerator(context);
    mIconGenerator.setContentView(makeSquareTextView(context));
    mIconGenerator.setTextAppearance(R.style.amu_ClusterIcon_TextAppearance);
    mIconGenerator.setBackground(makeClusterBackground());
    mClusterManager = clusterManager;
}
 
Example #26
Source File: MapActivity.java    From Nimbus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    map_available=true;
    map=googleMap;

    map.moveCamera(CameraUpdateFactory.newCameraPosition(hamirpur));
    map.setMapType(GoogleMap.MAP_TYPE_HYBRID);


    map.addMarker(audi);
    map.addMarker(nescafe);
    map.addMarker(park);
    map.addMarker(juice);
    map.addMarker(ground);
    map.addMarker(oat);
    map.addMarker(sbi);
    map.addMarker(ekta);
    map.addMarker(h4);
    map.addMarker(pgh);
    map.addMarker(kbh);
    map.addMarker(g1);
    map.addMarker(nbh);
    map.addMarker(dbh);
    map.addMarker(mega);
    map.addMarker(mmh);
    map.addMarker(lib);
    map.addMarker(dept);

}
 
Example #27
Source File: EditCameraLocationActivity.java    From evercam-android with GNU Affero General Public License v3.0 5 votes vote down vote up
public void addMyLocationButtonClickListner() {
    mMap.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() {
        @Override
        public boolean onMyLocationButtonClick() {
            //TODO: Any custom actions

            if (ActivityCompat.checkSelfPermission(EditCameraLocationActivity.this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
                    && ActivityCompat.checkSelfPermission(EditCameraLocationActivity.this, android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {

                mMap.clear();

                LocationManager locationManager =
                        (LocationManager) getSystemService(LOCATION_SERVICE);

                Criteria criteria = new Criteria();
                String provider = locationManager.getBestProvider(criteria, false);
                location = locationManager.getLastKnownLocation(provider);

                if (location != null) {
                    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new
                            LatLng(location.getLatitude(),
                            location.getLongitude()), 15));
                    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
                    tappedLatLng = latLng;

                    mMap.addMarker(new MarkerOptions().position(latLng));

                    new CallMashapeAsync().execute();

                } else {

                    //Location Object is null May call Location Listener here
                }

            }

            return false;
        }
    });
}
 
Example #28
Source File: GoogleMapControllerImpl.java    From Companion-For-PUBG-Android with MIT License 5 votes vote down vote up
/**
 * Will overlay the current {@link GoogleMap} with tiles for PUBG.
 */
private void setUpMap() {
    final TileOverlayOptions overlayOptions = new TileOverlayOptions();
    overlayOptions.tileProvider(new PUBGTileProvider());
    this.googleMap.setMaxZoomPreference(5);
    this.googleMap.setMapType(GoogleMap.MAP_TYPE_NONE);
    this.googleMap.addTileOverlay(overlayOptions);
    this.googleMap.getUiSettings().setMapToolbarEnabled(false);
}
 
Example #29
Source File: PUBGMapFragment.java    From Companion-For-PUBG-Android with MIT License 5 votes vote down vote up
@Override
public void onMapReady(final GoogleMap googleMap) {
    if (googleMap != null) {
        this.mapController = new GoogleMapControllerImpl(getActivity(), googleMap);
    }

}
 
Example #30
Source File: MapSettingsActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap map)
{
	googleMap = map;

	UiSettings uiSettings = googleMap.getUiSettings();

	enableMyLocation();
	googleMap.setIndoorEnabled(true);
	googleMap.setBuildingsEnabled(true);
	googleMap.setTrafficEnabled(true);

	uiSettings.setCompassEnabled(true);
	uiSettings.setMyLocationButtonEnabled(true);
	uiSettings.setZoomControlsEnabled(true);
	uiSettings.setMapToolbarEnabled(true);
	uiSettings.setIndoorLevelPickerEnabled(true);

	uiSettings.setRotateGesturesEnabled(true);
	uiSettings.setScrollGesturesEnabled(true);
	uiSettings.setTiltGesturesEnabled(true);
	uiSettings.setZoomGesturesEnabled(true);
	uiSettings.setAllGesturesEnabled(true);

	googleMap.addMarker(new MarkerOptions().position(MADISON_SQUARE_GARDEN));
	googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(MADISON_SQUARE_GARDEN, 17));
}