use of com.google.android.gms.maps.model.BitmapDescriptor in project Pokemap by omkarmoghe.
the class MapWrapperFragment method updateMarkers.
private void updateMarkers() {
if (mGoogleMap != null) {
if (markerList != null && !markerList.isEmpty()) {
for (Iterator<Map.Entry<String, PokemonMarkerExtended>> pokemonIterator = markerList.entrySet().iterator(); pokemonIterator.hasNext(); ) {
Map.Entry<String, PokemonMarkerExtended> pokemonEntry = pokemonIterator.next();
CatchablePokemon catchablePokemon = pokemonEntry.getValue().getCatchablePokemon();
Marker marker = pokemonEntry.getValue().getMarker();
if (!showablePokemonIDs.contains(catchablePokemon.getPokemonId())) {
marker.remove();
pokemonIterator.remove();
} else {
if (catchablePokemon.getExpirationTimestampMs() == -1) {
futureMarkerList.put(catchablePokemon.getSpawnPointId(), pokemonEntry.getValue());
marker.setAlpha(0.6f);
marker.setSnippet(getString(R.string.pokemon_will_spawn));
continue;
}
long millisLeft = catchablePokemon.getExpirationTimestampMs() - System.currentTimeMillis();
if (millisLeft < 0) {
marker.remove();
pokemonIterator.remove();
} else {
marker.setSnippet(getExpirationBreakdown(millisLeft));
if (marker.isInfoWindowShown()) {
marker.showInfoWindow();
}
}
}
}
}
if (pokestopsList != null && !pokestopsList.isEmpty() && mPref.getShowPokestops()) {
for (Iterator<Map.Entry<String, PokestopMarkerExtended>> pokestopIterator = pokestopsList.entrySet().iterator(); pokestopIterator.hasNext(); ) {
Map.Entry<String, PokestopMarkerExtended> pokestopEntry = pokestopIterator.next();
final Pokestop pokestop = pokestopEntry.getValue().getPokestop();
final Marker marker = pokestopEntry.getValue().getMarker();
int markerSize = getResources().getDimensionPixelSize(R.dimen.pokestop_marker);
RemoteImageLoader.loadMapIcon(getActivity(), pokestop.hasLurePokemon() ? lurePokeStopImageUrl : pokeStopImageUrl, markerSize, markerSize, new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
marker.setIcon(bitmapDescriptor);
marker.setZIndex(pokestop.hasLurePokemon() ? 1.0f : 0.5f);
}
});
}
} else if (pokestopsList != null && !pokestopsList.isEmpty() && !mPref.getShowPokestops()) {
for (Iterator<Map.Entry<String, PokestopMarkerExtended>> pokestopIterator = pokestopsList.entrySet().iterator(); pokestopIterator.hasNext(); ) {
Map.Entry<String, PokestopMarkerExtended> pokestopEntry = pokestopIterator.next();
Marker marker = pokestopEntry.getValue().getMarker();
marker.remove();
pokestopIterator.remove();
}
}
if (gymsList != null && !gymsList.isEmpty() && mPref.getShowGyms()) {
for (Iterator<Map.Entry<String, GymMarkerExtended>> gymIterator = gymsList.entrySet().iterator(); gymIterator.hasNext(); ) {
Map.Entry<String, GymMarkerExtended> gymEntry = gymIterator.next();
final FortDataOuterClass.FortData gym = gymEntry.getValue().getGym();
final Marker marker = gymEntry.getValue().getMarker();
int markerSize = getResources().getDimensionPixelSize(R.dimen.gym_marker);
RemoteImageLoader.loadMapIcon(getActivity(), gymTeamImageUrls.get(gym.getOwnedByTeam().getNumber()), markerSize, markerSize, new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
marker.setIcon(bitmapDescriptor);
}
});
}
} else if (gymsList != null && !gymsList.isEmpty() && !mPref.getShowGyms()) {
for (Iterator<Map.Entry<String, GymMarkerExtended>> gymIterator = gymsList.entrySet().iterator(); gymIterator.hasNext(); ) {
Map.Entry<String, GymMarkerExtended> gymEntry = gymIterator.next();
Marker marker = gymEntry.getValue().getMarker();
marker.remove();
gymIterator.remove();
}
}
if (!mPref.getShowScannedPlaces() && userSelectedPositionCircles != null && !userSelectedPositionCircles.isEmpty()) {
for (Circle circle : userSelectedPositionCircles) {
circle.remove();
}
userSelectedPositionCircles.clear();
}
}
}
use of com.google.android.gms.maps.model.BitmapDescriptor in project Pokemap by omkarmoghe.
the class MapWrapperFragment method setGymsMarkers.
private void setGymsMarkers(final GymsEvent event) {
if (mGoogleMap != null) {
int markerSize = getResources().getDimensionPixelSize(R.dimen.gym_marker);
Collection<FortDataOuterClass.FortData> gyms = event.getGyms();
if (gyms != null && mPref.getShowGyms()) {
Set<String> markerKeys = gymsList.keySet();
for (final FortDataOuterClass.FortData gym : gyms) {
double distanceFromCenterInMeters = MapHelper.distance(new LatLng(event.getLatitude(), event.getLongitude()), new LatLng(gym.getLatitude(), gym.getLongitude())) * 1000;
if (!markerKeys.contains(gym.getId()) && distanceFromCenterInMeters <= MapHelper.convertStepsToRadius(mPref.getSteps())) {
RemoteImageLoader.loadMapIcon(getActivity(), gymTeamImageUrls.get(gym.getOwnedByTeam().getNumber()), markerSize, markerSize, new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
Marker marker = mGoogleMap.addMarker(new MarkerOptions().position(new LatLng(gym.getLatitude(), gym.getLongitude())).title(getString(R.string.gym)).icon(bitmapDescriptor).zIndex(MapHelper.LAYER_GYMS).anchor(0.5f, 0.5f));
// adding gyms to list to be removed on next search
gymsList.put(gym.getId(), new GymMarkerExtended(gym, marker));
}
});
}
}
}
updateMarkers();
} else {
showMapNotInitializedError();
}
}
use of com.google.android.gms.maps.model.BitmapDescriptor in project Pokemap by omkarmoghe.
the class MapWrapperFragment method setPokestopsMarkers.
private void setPokestopsMarkers(final PokestopsEvent event) {
if (mGoogleMap != null) {
int markerSize = getResources().getDimensionPixelSize(R.dimen.pokestop_marker);
Collection<Pokestop> pokestops = event.getPokestops();
if (pokestops != null && mPref.getShowPokestops()) {
Set<String> markerKeys = pokestopsList.keySet();
for (final Pokestop pokestop : pokestops) {
// radial boxing
double distanceFromCenterInMeters = MapHelper.distance(new LatLng(event.getLatitude(), event.getLongitude()), new LatLng(pokestop.getLatitude(), pokestop.getLongitude())) * 1000;
if (!markerKeys.contains(pokestop.getId()) && distanceFromCenterInMeters <= MapHelper.convertStepsToRadius(mPref.getSteps())) {
RemoteImageLoader.loadMapIcon(getActivity(), pokestop.hasLurePokemon() ? lurePokeStopImageUrl : pokeStopImageUrl, markerSize, markerSize, new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
Marker marker = mGoogleMap.addMarker(new MarkerOptions().position(new LatLng(pokestop.getLatitude(), pokestop.getLongitude())).title(getString(R.string.pokestop)).icon(bitmapDescriptor).zIndex(MapHelper.LAYER_POKESTOPS).alpha(pokestop.hasLurePokemon() ? 1.0f : 0.5f).anchor(0.5f, 0.5f));
//adding pokemons to list to be removed on next search
pokestopsList.put(pokestop.getId(), new PokestopMarkerExtended(pokestop, marker));
}
});
}
}
}
updateMarkers();
} else {
showMapNotInitializedError();
}
}
use of com.google.android.gms.maps.model.BitmapDescriptor in project Remindy by abicelis.
the class PlaceViewHolder method updateMapView.
private void updateMapView() {
if (mCurrent != null) {
mMap.clear();
// Add a marker for this item and set the camera
BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.icon_marker);
LatLng loc = new LatLng(mCurrent.getLatitude(), mCurrent.getLongitude());
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, 13f));
mMap.addMarker(new MarkerOptions().position(loc).icon(icon));
// // Set the map type back to normal.
// mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
}
Aggregations