Skip to content
Snippets Groups Projects
Commit 0cca2e86 authored by chan24's avatar chan24
Browse files

nav my location added

parent 35bf03d8
No related branches found
No related tags found
No related merge requests found
......@@ -39,4 +39,5 @@ dependencies {
apply plugin: 'com.google.gms.google-services'
\ No newline at end of file
......@@ -52,7 +52,10 @@
<activity android:name=".ProfileActivity" />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps"></activity>
android:label="@string/title_activity_maps" />
<activity
android:name=".MapsActivityLocation"
android:label="@string/title_activity_maps_location"></activity>
</application>
</manifest>
\ No newline at end of file
package com.example.chan24.smartplanner;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivityLocation extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps_location);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered 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 will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
/* // Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));*/
mMap = googleMap;
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
return;
}
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setCompassEnabled(true);
mMap.getUiSettings().setZoomControlsEnabled(true);
}
}
......@@ -85,7 +85,7 @@ public class UserArea extends AppCompatActivity {
break;
case R.id.my_location :
Intent i1 =new Intent(getApplicationContext(),MapsActivity.class);
Intent i1 =new Intent(getApplicationContext(),MapsActivityLocation.class);
startActivity(i1);
mDrawerLayout.closeDrawers();
break;
......
......@@ -6,7 +6,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainCoordinatorLayout"
android:layout_width="match_parent"
android:layout_height="500dp"
android:layout_height="550dp"
android:fitsSystemWindows="true"
tools:context=".MapsActivity">
......@@ -15,7 +15,7 @@
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="500dp"
android:layout_height="550dp"
tools:context="com.example.chan24.smartplanner.MapsActivity" />
......
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.chan24.smartplanner.MapsActivityLocation" />
......@@ -3,4 +3,5 @@
<string name="title_activity_maps">Map</string>
<string name="open">Open</string>
<string name="close">Close</string>
<string name="title_activity_maps_location">Map</string>
</resources>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment