Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Merge branch 'maps'
Browse files Browse the repository at this point in the history
  • Loading branch information
anksh committed Feb 19, 2016
2 parents 7803984 + 7b924b3 commit 05d9ea2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/com/mhacks/android/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

// Add the toolbar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected Object doInBackground(Object... args){
bMapOptions.inSampleSize = 4;
options = new GroundOverlayOptions()
.image(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(activity
.getResources(), R.drawable.map_no_edges, bMapOptions)))
.getResources(), R.drawable.grand_map, bMapOptions)))
.positionFromBounds(bounds);
return null;
}
Expand Down
28 changes: 23 additions & 5 deletions app/src/main/java/com/mhacks/android/ui/map/MapViewFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.android.gms.maps.model.GroundOverlayOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.mhacks.android.data.model.Location;

Expand All @@ -36,6 +37,7 @@ public class MapViewFragment extends Fragment implements AdapterView.OnItemSelec

public static final String TAG = "MapViewFragment";
public static final String MAP_PIN = "mapPin";
private ArrayList<Marker> mMarkers = new ArrayList<>();

//Views
private View mMapFragView;
Expand All @@ -47,7 +49,6 @@ public class MapViewFragment extends Fragment implements AdapterView.OnItemSelec
@Nullable
private GroundOverlayOptions option = null;

// NetworkManager networkManager = NetworkManager.getInstance();
private static final LatLng NORTHEAST = new LatLng(42.29353, -83.713641);
private static final LatLng SOUTHWEST = new LatLng(42.29182, -83.716611);
private static final LatLngBounds CORNERS = new LatLngBounds(SOUTHWEST, NORTHEAST);
Expand Down Expand Up @@ -95,15 +96,21 @@ public void run() {
else{
if(gMap != null){
ArrayList<Location> _locations = LocationsQueue.locations;
float zoom = (float) 16.0;
if(!_locations.isEmpty()){
gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(42.2919466, -83.7153427), 16));
double swLat = 42.287503;
double swLong = -83.718795;
for (int i = 0; i < _locations.size(); i++){
gMap.addMarker(new MarkerOptions().position(new LatLng(_locations.get(i).getLatitude(),
if(_locations.get(i).getLatitude() < swLat || _locations.get(i).getLongitude() < swLong) zoom = (float) 13.25;
Marker _marker = gMap.addMarker(new MarkerOptions().position(new LatLng(_locations.get(i).getLatitude(),
_locations.get(i).getLongitude())).title(_locations.get(i).getName()));
mMarkers.add(_marker);
}

_locations.clear();
}
}
gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(42.2919466, -83.7153427), zoom));
}
else{
Log.e(TAG, "Map was not loaded");
}
Expand All @@ -113,6 +120,10 @@ public void run() {

@Override
public void onDestroyView() {
for(Marker _marker: mMarkers){
_marker.remove();
}
mMarkers.clear();
super.onDestroyView();
}

Expand All @@ -136,13 +147,20 @@ public void onMapReady(GoogleMap map){
mapLock.unlock();

ArrayList<Location> _locations = LocationsQueue.locations;
float zoom = (float) 16.0;
if(!_locations.isEmpty()){
double swLat = 42.287503;
double swLong = -83.718795;
for (int i = 0; i < _locations.size(); i++){
gMap.addMarker(new MarkerOptions().position(new LatLng(_locations.get(i).getLatitude(),
if(_locations.get(i).getLatitude() < swLat || _locations.get(i).getLongitude() < swLong) zoom = (float) 13.25;
Marker _marker = gMap.addMarker(new MarkerOptions().position(new LatLng(_locations.get(i).getLatitude(),
_locations.get(i).getLongitude())).title(_locations.get(i).getName()));
mMarkers.add(_marker);
}

_locations.clear();
}
gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(42.2919466, -83.7153427), zoom));

gMap.getUiSettings().setMyLocationButtonEnabled(true);
//TODO: stop it from complaining about disabled permissions
Expand Down
Binary file added app/src/main/res/drawable/grand_map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 05d9ea2

Please sign in to comment.