use of com.google.android.gms.maps.model.BitmapDescriptor in project iosched by google.
the class MapUtils method createVenueMarker.
/**
* Creates a marker for the venue.
*/
public static MarkerOptions createVenueMarker(LatLng position) {
final String title = "VENUE";
final BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.map_marker_venue);
return new MarkerOptions().position(position).title(title).icon(icon).visible(false);
}
use of com.google.android.gms.maps.model.BitmapDescriptor in project iosched by google.
the class MapUtils method createIconMarker.
/**
* Creates a marker for an icon. The icon is selected in {@link #getDrawableForIconType(Context,
* String)} and anchored at the bottom center for the location.
*/
public static MarkerOptions createIconMarker(final String iconType, final String id, LatLng position, Context context) {
final int iconResource = getDrawableForIconType(context, iconType);
if (iconResource < 1) {
// Not a valid icon type.
return null;
}
final BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(iconResource);
return new MarkerOptions().position(position).title(id).icon(icon).anchor(0.5f, 1f).visible(false);
}
use of com.google.android.gms.maps.model.BitmapDescriptor in project android-maps-utils by googlemaps.
the class GeoJsonPointStyleTest method testIcon.
public void testIcon() throws Exception {
BitmapDescriptor icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN);
pointStyle.setIcon(icon);
assertEquals(icon, pointStyle.getIcon());
assertEquals(icon, pointStyle.toMarkerOptions().getIcon());
}
use of com.google.android.gms.maps.model.BitmapDescriptor in project android-maps-utils by googlemaps.
the class GeoJsonDemoActivity method addColorsToMarkers.
/**
* Adds a point style to all features to change the color of the marker based on its magnitude
* property
*/
private void addColorsToMarkers(GeoJsonLayer layer) {
// Iterate over all the features stored in the layer
for (GeoJsonFeature feature : layer.getFeatures()) {
// Check if the magnitude property exists
if (feature.getProperty("mag") != null && feature.hasProperty("place")) {
double magnitude = Double.parseDouble(feature.getProperty("mag"));
// Get the icon for the feature
BitmapDescriptor pointIcon = BitmapDescriptorFactory.defaultMarker(magnitudeToColor(magnitude));
// Create a new point style
GeoJsonPointStyle pointStyle = new GeoJsonPointStyle();
// Set options for the point style
pointStyle.setIcon(pointIcon);
pointStyle.setTitle("Magnitude of " + magnitude);
pointStyle.setSnippet("Earthquake occured " + feature.getProperty("place"));
// Assign the point style to the feature
feature.setPointStyle(pointStyle);
}
}
}
use of com.google.android.gms.maps.model.BitmapDescriptor in project Pokemap by omkarmoghe.
the class MapWrapperFragment method setPokemonMarkers.
private void setPokemonMarkers(final List<CatchablePokemon> pokeList) {
int markerSize = getResources().getDimensionPixelSize(R.dimen.pokemon_marker);
if (mGoogleMap != null) {
Set<String> markerKeys = markerList.keySet();
Set<String> futureKeys = futureMarkerList.keySet();
for (final CatchablePokemon poke : pokeList) {
if (futureKeys.contains(poke.getSpawnPointId())) {
if (poke.getExpirationTimestampMs() > 1) {
futureMarkerList.get(poke.getSpawnPointId()).getMarker().remove();
futureKeys.remove(poke.getSpawnPointId());
futureMarkerList.remove(poke.getSpawnPointId());
markerKeys.remove(poke.getSpawnPointId());
markerList.remove(poke.getSpawnPointId());
}
}
if (!markerKeys.contains(poke.getSpawnPointId())) {
// checking if we need to show this pokemon
PokemonIdOuterClass.PokemonId pokemonId = poke.getPokemonId();
if (showablePokemonIDs.contains(pokemonId)) {
RemoteImageLoader.loadMapIcon(getActivity(), "http://serebii.net/pokemongo/pokemon/" + PokemonIdUtils.getCorrectPokemonImageId(pokemonId.getNumber()) + ".png", markerSize, markerSize, new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
//Setting marker since we got image
//int resourceID = getResources().getIdentifier("p" + poke.getPokemonId().getNumber(), "drawable", getActivity().getPackageName());
final Marker marker = mGoogleMap.addMarker(new MarkerOptions().position(new LatLng(poke.getLatitude(), poke.getLongitude())).title(PokemonIdUtils.getLocalePokemonName(getContext(), poke.getPokemonId().name())).icon(bitmapDescriptor).zIndex(MapHelper.LAYER_POKEMONS).anchor(0.5f, 0.5f));
//adding pokemons to list to be removed on next search
PokemonMarkerExtended markerExtended = new PokemonMarkerExtended(poke, marker);
markerList.put(poke.getSpawnPointId(), markerExtended);
MarkerRefreshController.getInstance().postMarker(markerExtended);
}
});
//Increase founded pokemon counter
nianticManager.setPokemonFound(nianticManager.getPokemonFound() + 1);
}
} else if (futureMarkerList.containsKey(poke.getSpawnPointId())) {
if (showablePokemonIDs.contains(poke.getPokemonId())) {
PokemonMarkerExtended futureMarker = futureMarkerList.get(poke.getSpawnPointId());
futureMarkerList.remove(futureMarker);
}
}
}
if (getView() != null) {
if (nianticManager.getCurrentScan() != nianticManager.getPendingSearch()) {
snackMe(getString(R.string.toast_still_searching, nianticManager.getPokemonFound()));
} else {
String text = nianticManager.getPokemonFound() > 0 ? getString(R.string.pokemon_found_new, nianticManager.getPokemonFound()) : getString(R.string.pokemon_found_none);
snackMe(text);
nianticManager.resetSearchCount();
}
}
updateMarkers();
} else {
showMapNotInitializedError();
}
}
Aggregations