Search in sources :

Example 6 with BitmapDescriptor

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);
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) BitmapDescriptor(com.google.android.gms.maps.model.BitmapDescriptor)

Example 7 with BitmapDescriptor

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);
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) BitmapDescriptor(com.google.android.gms.maps.model.BitmapDescriptor)

Example 8 with BitmapDescriptor

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());
}
Also used : BitmapDescriptor(com.google.android.gms.maps.model.BitmapDescriptor)

Example 9 with BitmapDescriptor

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);
        }
    }
}
Also used : GeoJsonFeature(com.google.maps.android.data.geojson.GeoJsonFeature) GeoJsonPointStyle(com.google.maps.android.data.geojson.GeoJsonPointStyle) BitmapDescriptor(com.google.android.gms.maps.model.BitmapDescriptor)

Example 10 with BitmapDescriptor

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();
    }
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) BitmapDescriptor(com.google.android.gms.maps.model.BitmapDescriptor) Marker(com.google.android.gms.maps.model.Marker) PokemonMarkerExtended(com.omkarmoghe.pokemap.models.map.PokemonMarkerExtended) PokemonIdOuterClass(POGOProtos.Enums.PokemonIdOuterClass) CatchablePokemon(com.pokegoapi.api.map.pokemon.CatchablePokemon) Bitmap(android.graphics.Bitmap) LatLng(com.google.android.gms.maps.model.LatLng) RemoteImageLoader(com.omkarmoghe.pokemap.helpers.RemoteImageLoader)

Aggregations

BitmapDescriptor (com.google.android.gms.maps.model.BitmapDescriptor)14 MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)7 Bitmap (android.graphics.Bitmap)5 LatLng (com.google.android.gms.maps.model.LatLng)5 Marker (com.google.android.gms.maps.model.Marker)5 RemoteImageLoader (com.omkarmoghe.pokemap.helpers.RemoteImageLoader)4 FortDataOuterClass (POGOProtos.Map.Fort.FortDataOuterClass)2 SuppressLint (android.annotation.SuppressLint)2 Point (com.google.maps.android.geometry.Point)2 GymMarkerExtended (com.omkarmoghe.pokemap.models.map.GymMarkerExtended)2 PokemonMarkerExtended (com.omkarmoghe.pokemap.models.map.PokemonMarkerExtended)2 PokestopMarkerExtended (com.omkarmoghe.pokemap.models.map.PokestopMarkerExtended)2 Pokestop (com.pokegoapi.api.map.fort.Pokestop)2 CatchablePokemon (com.pokegoapi.api.map.pokemon.CatchablePokemon)2 PokemonIdOuterClass (POGOProtos.Enums.PokemonIdOuterClass)1 GoogleMap (com.google.android.gms.maps.GoogleMap)1 Circle (com.google.android.gms.maps.model.Circle)1 GroundOverlay (com.google.android.gms.maps.model.GroundOverlay)1 GroundOverlayOptions (com.google.android.gms.maps.model.GroundOverlayOptions)1 GeoJsonFeature (com.google.maps.android.data.geojson.GeoJsonFeature)1