Skip to content

Commit e9939c4

Browse files
socrates2510comann
authored andcommitted
Layers for markers, pokemons on top (#222)
* - Check permissions to set my location - Change scanning location marker to a smaller one - Center pokemon markers - Add pokemon markers to a hashmap to keep track of all the previous scans - Update marker snipper with current expiration, added a update markers method - Call the update markers on resume and after scanning * Show how many new pokemon where found after the latest scan. * - Moved PokemonMarkerExtended to map package. * Removed hack for negative expiration. Assuming that a -1 expiration means that the pokemon is expired and will be removed in the new update. * Change the calls to the to get the range search to MainActivity and let the events and threads do the job of getting multiple steps at a time. * Remove conflicted name class LatLng and add MapHelper to have the distance and translatePoint methods static. * Remove extra loop in Niamtic Manager * Make hex weaker. * Fix niantic manager to prevent double call to range search. * Show pokestops * Add lured pokestops. * Use show scanned locations and pokestops to show them or not. * Add Clear Map menu item. Close suggestion on first search. * Hide password in settings * Layers for scanned locations, pokestops, gyms and pokemons.
1 parent 4687b99 commit e9939c4

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

app/src/main/java/com/omkarmoghe/pokemap/helpers/MapHelper.java

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ public class MapHelper {
1010
//Radius of the Earth in km
1111
public static final double EARTH = 6371;
1212

13+
// Layers
14+
public static final float LAYER_SCANNED_LOCATIONS = 0;
15+
public static final float LAYER_MY_SEARCH = 50;
16+
public static final float LAYER_POKESTOPS = 100;
17+
public static final float LAYER_GYMS = 150;
18+
public static final float LAYER_POKEMONS = 200;
19+
1320
/**
1421
* Returns the distance from 'this' point to destination point (using haversine formula).
1522
*

app/src/main/java/com/omkarmoghe/pokemap/views/map/MapWrapperFragment.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.pm.PackageManager;
55
import android.graphics.Bitmap;
66
import android.graphics.BitmapFactory;
7+
import android.graphics.Color;
78
import android.location.Location;
89
import android.os.Bundle;
910
import android.support.annotation.Nullable;
@@ -35,6 +36,7 @@
3536
import com.omkarmoghe.pokemap.controllers.app_preferences.PokemapAppPreferences;
3637
import com.omkarmoghe.pokemap.controllers.app_preferences.PokemapSharedPreferences;
3738
import com.omkarmoghe.pokemap.controllers.map.LocationManager;
39+
import com.omkarmoghe.pokemap.helpers.MapHelper;
3840
import com.omkarmoghe.pokemap.helpers.RemoteImageLoader;
3941
import com.omkarmoghe.pokemap.models.events.CatchablePokemonEvent;
4042
import com.omkarmoghe.pokemap.models.events.ClearMapEvent;
@@ -303,6 +305,7 @@ public void onFetch(Bitmap bitmap) {
303305

304306
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
305307
marker.setIcon(bitmapDescriptor);
308+
marker.setZIndex(pokestop.hasLurePokemon() ? 1.0f : 0.5f);
306309
}
307310
}
308311
);
@@ -405,6 +408,8 @@ public void onFetch(Bitmap bitmap) {
405408
.position(new LatLng(pokestop.getLatitude(), pokestop.getLongitude()))
406409
.title(getString(R.string.pokestop))
407410
.icon(bitmapDescriptor)
411+
.zIndex(MapHelper.LAYER_POKESTOPS)
412+
.alpha(pokestop.hasLurePokemon() ? 1.0f : 0.5f)
408413
.anchor(0.5f, 0.5f));
409414

410415
//adding pokemons to list to be removed on next search
@@ -456,6 +461,7 @@ public void onFetch(Bitmap bitmap) {
456461
.position(new LatLng(gym.getLatitude(), gym.getLongitude()))
457462
.title(getString(R.string.gym))
458463
.icon(bitmapDescriptor)
464+
.zIndex(MapHelper.LAYER_GYMS)
459465
.anchor(0.5f, 0.5f));
460466

461467
// adding gyms to list to be removed on next search
@@ -503,6 +509,7 @@ public void onFetch(Bitmap bitmap) {
503509
.position(new LatLng(poke.getLatitude(), poke.getLongitude()))
504510
.title(PokemonIdUtils.getLocalePokemonName(getContext(), poke.getPokemonId().name()))
505511
.icon(bitmapDescriptor)
512+
.zIndex(MapHelper.LAYER_POKEMONS)
506513
.anchor(0.5f, 0.5f));
507514
//adding pokemons to list to be removed on next search
508515
markerList.put(poke.getSpawnPointId(), new PokemonMarkerExtended(poke, marker));
@@ -677,10 +684,12 @@ private void drawCatchedPokemonCircle(double latitude, double longitude) {
677684
if (mPref.getShowScannedPlaces()) {
678685

679686
double radiusInMeters = 100.0;
680-
int strokeColor = 0x4400CCFF; // outline
681-
int shadeColor = 0x4400CCFF; // fill
682-
683-
CircleOptions circleOptions = new CircleOptions().center(new LatLng(latitude, longitude)).radius(radiusInMeters).fillColor(shadeColor).strokeColor(strokeColor).strokeWidth(8);
687+
int shadeColor = 0x2200CCFF; // fill
688+
CircleOptions circleOptions = new CircleOptions()
689+
.center(new LatLng(latitude, longitude))
690+
.radius(radiusInMeters).fillColor(shadeColor)
691+
.strokeColor(Color.TRANSPARENT)
692+
.zIndex(MapHelper.LAYER_SCANNED_LOCATIONS);
684693
userSelectedPositionCircles.add(mGoogleMap.addCircle(circleOptions));
685694
}
686695
}
@@ -730,6 +739,7 @@ private void drawMarker(LatLng position){
730739
.title(getString(R.string.position_picked))
731740
.icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getContext().getResources(),
732741
R.drawable.ic_my_location_white_24dp)))
742+
.zIndex(MapHelper.LAYER_MY_SEARCH)
733743
.anchor(0.5f, 0.5f));
734744
} else {
735745
showMapNotInitializedError();

0 commit comments

Comments
 (0)