Java 类com.google.android.gms.maps.model.BitmapDescriptor 实例源码

项目:ExtraMapUtils    文件:AppUtils.java   
public static 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);
        }
    }
}
项目:SpaceRace    文件:PathDrawer.java   
public Builder() {

            Bitmap toScale = BitmapFactory.decodeResource(
                    SpaceRace.getAppContext().getResources(),
                    DEFAULT_PIECE_DISPLAYED);
            toScale = Bitmap.createScaledBitmap(toScale,
                    ICON_DIMENSION,
                    ICON_DIMENSION,
                    false);

            BitmapDescriptor defaultIcon = BitmapDescriptorFactory.fromBitmap(toScale);

            this.firstNodeIcon = defaultIcon;
            this.middleNodeIcon = defaultIcon;
            this.lastNodeIcon = defaultIcon;
            this.map = null;
            this.path = null;
        }
项目:1617PROJ1Bloeddonatie-app    文件:Location.java   
public MarkerOptions getMarker() {
    BitmapDescriptor markerIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_location_red);
    BitmapDescriptor markerIconMobile = BitmapDescriptorFactory.fromResource(R.drawable.ic_location_mobile_red);

    this.marker.position(this.getCoordinates());
    this.marker.title(this.name);
    this.marker.snippet(this.getAddress() + this.getDates());

    if(this.isMobile == null) {
        this.marker.icon(markerIcon);
    } else {
        if(this.isMobile == true) {
            this.marker.icon(markerIconMobile);
        } else {
            this.marker.icon(markerIcon);
        }
    }


    return this.marker;
}
项目:Remindy    文件:PlaceViewHolder.java   
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);
        }
    }
项目:AstronomyTourPadova    文件:AtMarker.java   
private BitmapDescriptor bitmapDescriptorFromVector(Context context, int vectorResId) {
    Drawable vectorDrawable = ContextCompat.getDrawable(context, vectorResId);
    vectorDrawable.setBounds(0, 0, vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight());
    Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    vectorDrawable.draw(canvas);
    return BitmapDescriptorFactory.fromBitmap(bitmap);
}
项目:Android-Programming-BigNerd    文件:LocatrFragment.java   
private void updateUI() {
    if (mMap == null || mMapImage == null) {
        return;
    }
    Log.d(TAG, "updateUI: ");
    LatLng itemPoint = new LatLng(mMapItem.getLat(), mMapItem.getLon());
    LatLng myPoint = new LatLng(mCurrentLocation.getLatitude(),
            mCurrentLocation.getLongitude());
    BitmapDescriptor itemBitmap = BitmapDescriptorFactory.fromBitmap(mMapImage);
    MarkerOptions itemMarker = new MarkerOptions()
            .position(itemPoint)
            .icon(itemBitmap);
    MarkerOptions myMarker = new MarkerOptions()
            .position(myPoint);
    mMap.clear();
    mMap.addMarker(itemMarker);
    mMap.addMarker(myMarker);
    LatLngBounds bounds = new LatLngBounds.Builder()
            .include(itemPoint)
            .include(myPoint)
            .build();
    int margin = getResources().getDimensionPixelSize(R.dimen.map_inset_margin);
    CameraUpdate update = CameraUpdateFactory.newLatLngBounds(bounds, margin);
    mMap.animateCamera(update);
}
项目:google-maps-clustering    文件:DefaultIconGenerator.java   
@NonNull
private BitmapDescriptor createClusterIcon(int clusterBucket) {
    @SuppressLint("InflateParams")
    TextView clusterIconView = (TextView) LayoutInflater.from(mContext)
            .inflate(R.layout.map_cluster_icon, null);
    clusterIconView.setBackground(createClusterBackground());
    clusterIconView.setTextColor(mIconStyle.getClusterTextColor());
    clusterIconView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
            mIconStyle.getClusterTextSize());

    clusterIconView.setText(getClusterIconText(clusterBucket));

    clusterIconView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
    clusterIconView.layout(0, 0, clusterIconView.getMeasuredWidth(),
            clusterIconView.getMeasuredHeight());

    Bitmap iconBitmap = Bitmap.createBitmap(clusterIconView.getMeasuredWidth(),
            clusterIconView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(iconBitmap);
    clusterIconView.draw(canvas);

    return BitmapDescriptorFactory.fromBitmap(iconBitmap);
}
项目:RoadLab-Pro    文件:MeasurementsGoogleMapHelper.java   
private void addTag(Context context, GoogleMap map, TagModel item, boolean addCache) {
    LatLng location = new LatLng(item.getLatitude(), item.getLongitude());
    BitmapDescriptor tagIcon = getTagIcon(item.getRoadCondition());
    Marker marker = map.addMarker(new MarkerOptions()
            .position(location)
            .icon(tagIcon)
            .anchor(0.5f, 0.5f)
            .title(item.getName())
            .snippet(item.getDescription()));
    if (addCache && markersCache != null) {
        markersCache.put(marker, item);
    }
}
项目:Privy    文件:NetworkRequest.java   
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    cursor.moveToFirst();

    while (!cursor.isAfterLast()) {
        MarkerData data = new MarkerData();
        setCursorData(cursor, data);
        BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE);
        Marker temp = mMap.addMarker(new MarkerOptions().position(new LatLng(data.getGeometry().getLocation().getLat(), data.getGeometry().getLocation().getLng())).title(data.getName()).icon(bitmapDescriptor));
        hm.put(temp.getId(), data);

        cursor.moveToNext();

        Log.d(DEBUG, "Offline data : " + data);
    }

    addMarkerListner();
}
项目:Capstone    文件:MapActivity.java   
/**
 * Manipulates the map once available.
 * This callback is triggered when the map is ready to be used.
 * This is where we can add markers or lines, add listeners or move the camera. In this case,
 * we just add a marker near Sydney, Australia.
 * If Google Play services is not installed on the device, the user will be prompted to install
 * it inside the SupportMapFragment. This method will only be triggered once the user has
 * installed Google Play services and returned to the app.
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    // User loader to fetch data from SQLite
    getSupportLoaderManager().initLoader(PLACE_MAP_LOADER, null, MapActivity.this);

    Drawable circle = ContextCompat.getDrawable(MapActivity.this, R.drawable.ic_been_here);
    Canvas canvas = new Canvas();
    Bitmap bitmap = Bitmap.createBitmap(circle.getIntrinsicWidth(), circle.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    canvas.setBitmap(bitmap);
    circle.setBounds(0, 0, circle.getIntrinsicWidth(), circle.getIntrinsicHeight());
    circle.draw(canvas);
    BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(bitmap);


    // Add a marker in Sydney and move the camera
    LatLng currentLocation = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
    mMap.addMarker(new MarkerOptions().position(currentLocation).title("Here you are!").icon(icon));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(currentLocation));
    mMap.animateCamera(CameraUpdateFactory.zoomTo(13.0f)); // zoom Range is 2.0 to 21.0

}
项目:Bloop    文件:BootprintMapFragment.java   
private void placeBootprint(LatLng latLng, float direction) {
    if (mMap != null) {
        final BitmapDescriptor bootprint;
        // pick left/right print
        if (mTotalSteps++ % 2 == 0) {
            bootprint = mLeftBootprint;
        } else {
            bootprint = mRightBootprint;
        }


        final GroundOverlay overlay = mMap.addGroundOverlay(
                new GroundOverlayOptions().position(
                        latLng,
                        BOOTPRINT_SIZE_METERS
                ).bearing(
                        (float) (direction / Math.PI * 180d)
                ).image(bootprint)
        );

        mBootprintLocations.add(overlay);
        removeAndUpdateBootprints();
    }
}
项目:android-OurStreets    文件:ViewUtils.java   
/**
 * Creates a {@link BitmapDescriptor} from  a drawable.
 * This is particularly useful for {@link GoogleMap} {@link Marker}s.
 *
 * @param drawable The drawable that should be a {@link BitmapDescriptor}.
 * @return The created {@link BitmapDescriptor}.
 */
@NonNull
public static BitmapDescriptor getBitmapDescriptorFromDrawable(@NonNull Drawable drawable) {
    BitmapDescriptor bitmapDescriptor;
    // Usually the pin could be loaded via BitmapDescriptorFactory directly.
    // The target map_pin is a VectorDrawable which is currently not supported
    // within BitmapDescriptors.
    int width = drawable.getIntrinsicWidth();
    int height = drawable.getIntrinsicHeight();
    drawable.setBounds(0, 0, width, height);
    Bitmap markerBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(markerBitmap);
    drawable.draw(canvas);
    bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(markerBitmap);
    return bitmapDescriptor;
}
项目:Saude-no-Mapa    文件:EstablishmentInteractorImpl.java   
private BitmapDescriptor getBitmapDescriptorForCategory(String categoria) {
    BitmapDescriptor mapIcon;
    if (categoria.contains("consultório")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_consultorio);
    } else if (categoria.contains("clínica")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_clinica);
    } else if (categoria.contains("laboratório")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_laboratorio);
    } else if (categoria.contains("urgência")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_urgente);
    } else if (categoria.contains("hospital")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_hospital);
    } else if (categoria.contains("atendimento domiciliar")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_domiciliar);
    } else if (categoria.contains("posto de saúde")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_urgente);
    } else if (categoria.contains("samu")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_samu);
    } else {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_urgente);
    }

    return mapIcon;
}
项目:Saude-no-Mapa    文件:EmergencyInteractorImpl.java   
private BitmapDescriptor getBitmapDescriptorForCategory(String categoria) {
    BitmapDescriptor mapIcon;
    if (categoria.contains("consultório")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_consultorio);
    } else if (categoria.contains("clínica")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_clinica);
    } else if (categoria.contains("laboratório")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_laboratorio);
    } else if (categoria.contains("urgência")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_urgente);
    } else if (categoria.contains("hospital")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_hospital);
    } else if (categoria.contains("atendimento domiciliar")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_domiciliar);
    } else if (categoria.contains("posto de saúde")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_urgente);
    } else if (categoria.contains("samu")) {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_samu);
    } else {
        mapIcon = BitmapDescriptorFactory.fromResource(R.drawable.ic_urgente);
    }

    return mapIcon;
}
项目:SIT    文件:PlanZoneMapFragment.java   
/**
 * Drw polyline on the Google Map from first and last LatLng
 * @param first start point of the polyline to draw
 * @param last last point of the polyline to draw
 */
public void drawLine(LatLng first, LatLng last){
    // First you need rotate the bitmap of the arrowhead somewhere in your code
    float rotationDegrees = (float) LatLngUtils.angleFromCoordinate(last.latitude, last.longitude, first.latitude, first.longitude);

    // Create the rotated arrowhead bitmap
    Bitmap arrow = BitmapFactory.decodeResource(getResources(), R.drawable.arrow);
    BitmapDescriptor bitmapDescriptorFactory = BitmapDescriptorFactory.fromBitmap(arrow);
    // Get the middle position
    LatLng middlePos = LatLngUtils.midPoint(first.latitude, first.longitude, last.latitude, last.longitude);
    // Now we are gonna to add a marker
    Marker mArrowhead = googleMap.addMarker(new MarkerOptions()
            .position(middlePos)
            .flat(true)
            .anchor(0.5f, 0.5f)
            .rotation(rotationDegrees)
            .icon(bitmapDescriptorFactory));

    Polyline line = googleMap.addPolyline((new PolylineOptions())
            .add(first, last).width(3).color(Color.parseColor("#9b24a6"))
            .geodesic(true));

    polylines.add(new Pair<Polyline, Marker>(line, mArrowhead));
}
项目:SIT    文件:VisualisationMapFragment.java   
/**
 * Drw polyline on the Google Map from first and last LatLng
 * @param first start point of the polyline to draw
 * @param last last point of the polyline to draw
 */
public void drawLine(LatLng first, LatLng last){
    // First you need rotate the bitmap of the arrowhead somewhere in your code
    float rotationDegrees = (float) LatLngUtils.angleFromCoordinate(last.latitude, last.longitude, first.latitude, first.longitude);

    // Create the rotated arrowhead bitmap
    Bitmap arrow = BitmapFactory.decodeResource(getResources(), R.drawable.arrow);
    BitmapDescriptor bitmapDescriptorFactory = BitmapDescriptorFactory.fromBitmap(arrow);
    // Get the middle position
    LatLng middlePos = LatLngUtils.midPoint(first.latitude, first.longitude, last.latitude, last.longitude);
    // Now we are gonna to add a marker
    Marker mArrowhead = googleMap.addMarker(new MarkerOptions()
            .position(middlePos)
            .flat(true)
            .anchor(0.5f, 0.5f)
            .rotation(rotationDegrees)
            .icon(bitmapDescriptorFactory));

    Polyline line = googleMap.addPolyline((new PolylineOptions())
            .add(first, last).width(3).color(Color.parseColor("#9b24a6"))
            .geodesic(true));

    polylines.add(new Pair<Polyline, Marker>(line, mArrowhead));
}
项目:Sociadee    文件:MapWrapperFragment.java   
private BitmapDescriptor createMarker(Drawable profilePic)
{
    Drawable[] layers = new Drawable[2];
    layers[0] = getResources().getDrawable(R.drawable.blue_marker);
    layers[1] = profilePic;
    LayerDrawable layerDrawable = new LayerDrawable(layers);

    Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);

   // layerDrawable.setLayerInset(0, 0, 0, 0, 0);
    layerDrawable.setLayerInset(1, 15, 13, 16, 18);
    layerDrawable.setBounds(0, 0, 100, 100);
    layerDrawable.draw(new Canvas(b));
    BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(b);

    return icon;
}
项目:trolley-tracker-android-client    文件:IconFactory.java   
public static BitmapDescriptor getStopIcon(Context context, int color){
    if(stopIcons.containsKey(color)){
        return stopIcons.get(color);
    }

    Drawable d = ContextCompat.getDrawable(context, R.drawable.gmap_stop);
    Drawable m = ContextCompat.getDrawable(context, R.drawable.trolley_gmap_stop_mask);

    m.setColorFilter(color, PorterDuff.Mode.SRC_IN);

    int width = d.getIntrinsicWidth();
    width = width > 0 ? width : 1;
    int height = d.getIntrinsicHeight();
    height = height > 0 ? height : 1;

    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    d.draw(canvas);
    m.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    m.draw(canvas);

    BitmapDescriptor stopIcon = BitmapDescriptorFactory.fromBitmap(bitmap);
    stopIcons.put(color, stopIcon);
    return stopIcon;
}
项目:trolley-tracker-android-client    文件:IconFactory.java   
public static BitmapDescriptor getTrolleyIcon(Context context, int color){
    if(trolleyIcons.containsKey(color)){
        return trolleyIcons.get(color);
    }

    Drawable d = ContextCompat.getDrawable(context, R.drawable.marker_border);
    Drawable m = ContextCompat.getDrawable(context, R.drawable.marker_mask);

    m.setColorFilter(color, PorterDuff.Mode.SRC_IN);

    int width = d.getIntrinsicWidth();
    width = width > 0 ? width : 1;
    int height = d.getIntrinsicHeight();
    height = height > 0 ? height : 1;

    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    d.draw(canvas);
    m.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    m.draw(canvas);

    BitmapDescriptor trolleyIcon = BitmapDescriptorFactory.fromBitmap(bitmap);
    trolleyIcons.put(color, trolleyIcon);
    return trolleyIcon;
}
项目:android-sdk-examples    文件:MapsOverlayActivity.java   
/**
 * Sets bitmap of floor plan as ground overlay on Google Maps
 */
private void setupGroundOverlay(IAFloorPlan floorPlan, Bitmap bitmap) {

    if (mGroundOverlay != null) {
        mGroundOverlay.remove();
    }

    if (mMap != null) {
        BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
        IALatLng iaLatLng = floorPlan.getCenter();
        LatLng center = new LatLng(iaLatLng.latitude, iaLatLng.longitude);
        GroundOverlayOptions fpOverlay = new GroundOverlayOptions()
                .image(bitmapDescriptor)
                .zIndex(0.0f)
                .position(center, floorPlan.getWidthMeters(), floorPlan.getHeightMeters())
                .bearing(floorPlan.getBearing());

        mGroundOverlay = mMap.addGroundOverlay(fpOverlay);
    }
}
项目:AndroidMarkerClusteringMaps    文件:KmlRenderer.java   
/**
 * Adds ground overlays from a given URL onto the map
 *
 * @param groundOverlayUrl url of ground overlay
 * @param groundOverlays   hashmap of ground overlays to add to the map
 */
private void addGroundOverlayToMap(String groundOverlayUrl,
        HashMap<KmlGroundOverlay, GroundOverlay> groundOverlays, boolean containerVisibility) {
    BitmapDescriptor groundOverlayBitmap = BitmapDescriptorFactory
            .fromBitmap(mImagesCache.get(groundOverlayUrl));
    for (KmlGroundOverlay kmlGroundOverlay : groundOverlays.keySet()) {
        if (kmlGroundOverlay.getImageUrl().equals(groundOverlayUrl)) {
            GroundOverlayOptions groundOverlayOptions = kmlGroundOverlay.getGroundOverlayOptions()
                    .image(groundOverlayBitmap);
            GroundOverlay mapGroundOverlay = mMap.addGroundOverlay(groundOverlayOptions);
            if (containerVisibility == false) {
                mapGroundOverlay.setVisible(false);
            }
            groundOverlays.put(kmlGroundOverlay, mapGroundOverlay);
        }
    }
}
项目:message-samples-android    文件:MapViewActivity.java   
protected void loadMap(GoogleMap googleMap, String latlng) {
    if (googleMap != null) {
        googleMap.setMyLocationEnabled(true);

        String[] latlngAry = latlng.split(",");
        double lat = Double.parseDouble(latlngAry[0]);
        double lng = Double.parseDouble(latlngAry[1]);
        LatLng latlong = new LatLng(lat, lng);

        BitmapDescriptor defaultMarker =
                BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE);

        Marker marker = googleMap.addMarker(new MarkerOptions()
                .position(latlong)
                .title("My Location")
                .icon(defaultMarker));

        marker.showInfoWindow();
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlong, 18));
    }
}
项目:esnavi    文件:ShelterMarkerManager.java   
/**
 * マーカーのビットマップ情報を取得する。
 *
 * @param status 避難所状況
 * @return マーカーのビットマップ情報
 */
private static BitmapDescriptor getMarkerBitmapDescriptor(@Nullable ShelterStatus status) {
    final ShelterStatus state = status == null ? ShelterStatus.Unknown : status;
    final float bitmapDescriptorValue;

    switch (state) {
        case Unknown:
            bitmapDescriptorValue = BitmapDescriptorFactory.HUE_ORANGE;
            break;
        case Safety:
            bitmapDescriptorValue = BitmapDescriptorFactory.HUE_GREEN;
            break;
        case Waring:
            bitmapDescriptorValue = BitmapDescriptorFactory.HUE_RED;
            break;
        default:
            bitmapDescriptorValue = BitmapDescriptorFactory.HUE_ORANGE;
            break;
    }

    return BitmapDescriptorFactory.defaultMarker(bitmapDescriptorValue);
}
项目:android-maps-async-markers    文件:ClusterIconProvider.java   
@Override
public ClusterOptions getClusterOptions(List<Marker> list) {
    Bitmap bitmap = base.copy(Bitmap.Config.ARGB_8888, true);

    Rect bounds = new Rect();
    String text = String.valueOf(list.size());
    paint.getTextBounds(text, 0, text.length(), bounds);
    float x = bitmap.getWidth() / 2.0f;
    float y = (bitmap.getHeight() - bounds.height()) / 2.0f - bounds.top;

    Canvas canvas = new Canvas(bitmap);
    canvas.drawText(text, x, y, paint);
    BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(bitmap);

    return new ClusterOptions().anchor(0.5f, 0.5f).icon(icon);
}
项目:DumpsterMapAndroid    文件:MapActivity.java   
public BitmapDescriptor getIcon(int icon) {
    switch (icon) {
        case 1: return BitmapDescriptorFactory.fromAsset("binoculars.png");
           case 2: return BitmapDescriptorFactory.fromAsset("bread.png");
           case 3: return BitmapDescriptorFactory.fromAsset("broccoli.png");
           case 4: return BitmapDescriptorFactory.fromAsset("broken-computer.png");
           case 5: return BitmapDescriptorFactory.fromAsset("computer.png");
           case 6: return BitmapDescriptorFactory.fromAsset("cupcake.png");
           case 7: return BitmapDescriptorFactory.fromAsset("document.png");
           case 8: return BitmapDescriptorFactory.fromAsset("dumpster.png");
           case 9: return BitmapDescriptorFactory.fromAsset("error.png");
           case 10: return BitmapDescriptorFactory.fromAsset("firewood.png");
           case 11: return BitmapDescriptorFactory.fromAsset("flower.png");
           case 12: return BitmapDescriptorFactory.fromAsset("food.png");
           case 13: return BitmapDescriptorFactory.fromAsset("meat.png");
           case 14: return BitmapDescriptorFactory.fromAsset("milk.png");
           case 15: return BitmapDescriptorFactory.fromAsset("phone.png");
           case 16: return BitmapDescriptorFactory.fromAsset("police.png");
           case 17: return BitmapDescriptorFactory.fromAsset("shopping-cart.png");
           case 18: return BitmapDescriptorFactory.fromAsset("table.png");
           case 19: return BitmapDescriptorFactory.fromAsset("warning.png");
    }
    return BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN);
}
项目:TicketSearch    文件:StadiumsMapActivity.java   
/**
 * Creates and adds Marker symbol for each team's stadium to the map.
 */
private void setupStadiumMarkers() {
  if (mFeatureCollection == null || mFeatureCollection.getFeatures() == null) {
    Log.w(TAG, "Feature Collection is empty, cannot add stadium markers.");
    return;
  }

  // Use of a BiMap lets us treat either the team or it's marker as a key.
  mMapMarkers = HashBiMap.create(mFeatureCollection.getFeatures().size());

  BitmapDescriptor symbol = BitmapDescriptorFactory.fromResource(R.drawable.football_marker);
  LatLng location;
  String title;
  for (Feature feature : mFeatureCollection.getFeatures()) {
    location = new LatLng(feature.getGeometry().getLatitude(), feature.getGeometry().getLongitude());
    title = feature.getTeamName();
    Marker stadiumMarker = mMap.addMarker(new MarkerOptions().position(location).title(title).icon(symbol));
    mMapMarkers.put(feature, stadiumMarker);
  }
}
项目:Refugiate    文件:FragmentTab2.java   
public void addMaker()
{
    googleMap.clear();
    BitmapDescriptor bitmapDescriptor=BitmapDescriptorFactory.fromResource(R.drawable.ic_action_ubigeo);

    if(entidad.getNivel()==1)
        bitmapDescriptor=BitmapDescriptorFactory.fromResource(R.drawable.estrella1);
    else if(entidad.getNivel()==2)
        bitmapDescriptor=BitmapDescriptorFactory.fromResource(R.drawable.estrella2);
    else if(entidad.getNivel()==3)
        bitmapDescriptor=BitmapDescriptorFactory.fromResource(R.drawable.estrella3);
    else if(entidad.getNivel()==4)
        bitmapDescriptor=BitmapDescriptorFactory.fromResource(R.drawable.estrella4);
    else if(entidad.getNivel()==5)
        bitmapDescriptor=BitmapDescriptorFactory.fromResource(R.drawable.estrella5);
    googleMap.addMarker(new MarkerOptions().icon(bitmapDescriptor).position(new LatLng(entidad.getLatitud(), entidad.getLongitud())));
}
项目:AntennaMap    文件:Assets.java   
static BitmapDescriptor getSizedIcon(@NonNull Context context, double height) {
    final float density = context.getResources().getDisplayMetrics().density;
    final int index = (int)(height / 100);
    if (sizedIcons[index] == null) {
        // Generate icon
        final int size = (int) ((14 + index * 5) * density);
        final Drawable drawable = ContextCompat.getDrawable(context, R.drawable.a);
        if (drawable != null && drawable instanceof BitmapDrawable) {
            final BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
            final Bitmap bitmap = bitmapDrawable.getBitmap();
            final Bitmap bitmapScaled = Bitmap.createScaledBitmap(bitmap, size * 3 / 4, size, false);
            sizedIcons[index] = BitmapDescriptorFactory.fromBitmap(bitmapScaled);
        } else {
            return null; // Should never happen
        }
    }
    return sizedIcons[index];
}
项目:redningsselskapet    文件:KMLParser.java   
private static void addMarker(Placemark placemark) {
    double mLat = placemark.getPoint().getLat();
    double mLong = placemark.getPoint().getLong();

    if (mLat != 0 || mLong != 0) {
        int resource = mContext.getResources().getIdentifier(placemark.getStyle(), "drawable", mContext.getPackageName());
        BitmapDescriptor bmd = BitmapDescriptorFactory.fromResource(resource);

        MarkerOptions mo = new MarkerOptions();
        mo.position(new LatLng(mLat, mLong));
        mo.title(placemark.getName());

        if (placemark.getStyle().contains("rs_")) { // bare vise beskrivelse for båtene (telefonnummer)
            mo.snippet(placemark.getDescription());
        }

        if (bmd != null) {
            mo.icon(bmd);
        }

        mMap.addMarker(mo);
    }
}
项目:mtransit-for-android    文件:LazyMarker.java   
@Deprecated
public void setIcon(BitmapDescriptor icon) {
    if (marker != null) {
        marker.setIcon(icon);
    } else {
        markerOptions.icon(icon);
    }
    markerOptionsColor = null;
    markerOptionsSecondaryColor = null;
    markerOptionsDefaultColor = null;
    markerOptionsIconResId = null;
    if (markerOptionsContextWR != null) {
        markerOptionsContextWR.clear();
        markerOptionsContextWR = null;
    }
}
项目:warsjawa2013-android-squared-googled-preparation    文件:NearbyPlacesDisplayer.java   
private void displayNearbyPlaces(MeetupEvent event) {
    if (event.equals(currentEvent)) {
        return;
    }
    currentEvent = event;
    clearNearbyPlaces();
    NearbyPlacesList nearbyPlacesList = gmapsModel.getNearbyPlacesList(event);
    if (nearbyPlacesList != null) {
        BitmapDescriptor icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE);
        LatLngBounds.Builder builder = LatLngBounds.builder();
        for (NearbyPlace place : nearbyPlacesList.getResults()) {
            LatLng location = place.getLocation();
            Marker marker = map.addMarker(new MarkerOptions().position(location).title(place.getName()).icon(icon));
            markerNearbyPlaceMap.put(marker, place);
            builder.include(location);
        }
        map.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 30));
    }
}
项目:android-maps-utils    文件:GeoJsonDemoActivity.java   
/**
 * 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);
        }
    }
}
项目:android-maps-utils    文件:KmlRenderer.java   
/**
 * Adds ground overlays from a given URL onto the map
 *
 * @param groundOverlayUrl url of ground overlay
 * @param groundOverlays   hashmap of ground overlays to add to the map
 */
private void addGroundOverlayToMap(String groundOverlayUrl,
        HashMap<KmlGroundOverlay, GroundOverlay> groundOverlays, boolean containerVisibility) {
    BitmapDescriptor groundOverlayBitmap = BitmapDescriptorFactory
            .fromBitmap(getImagesCache().get(groundOverlayUrl));
    for (KmlGroundOverlay kmlGroundOverlay : groundOverlays.keySet()) {
        if (kmlGroundOverlay.getImageUrl().equals(groundOverlayUrl)) {
            GroundOverlayOptions groundOverlayOptions = kmlGroundOverlay.getGroundOverlayOptions()
                    .image(groundOverlayBitmap);
            GroundOverlay mapGroundOverlay = attachGroundOverlay(groundOverlayOptions);
            if (!containerVisibility) {
                mapGroundOverlay.setVisible(false);
            }
            groundOverlays.put(kmlGroundOverlay, mapGroundOverlay);
        }
    }
}
项目:Viajes    文件:MapFragment.java   
private void setupClusterManager() {
        // reference

        // clustering
        if(mMap!=null) {
            mClusterManager = new ClusterManager<>(getActivity(), mMap);
            mClusterManager.setRenderer(new DefaultClusterRenderer<Hotel>(getActivity(), mMap, mClusterManager) {
                @Override
                protected void onBeforeClusterItemRendered(Hotel item, MarkerOptions markerOptions) {
                    int size = getActivity().getResources().getDimensionPixelSize(R.dimen.fragment_map_marker_size);
                    Bitmap originalBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.markerfield);
                    Bitmap bitmap = BitmapScaler.scaleToFill(originalBitmap, size, size);
                    if(originalBitmap!=bitmap){
                        originalBitmap.recycle();
                    }

                    BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
                    markerOptions.title(item.getName());
                    markerOptions.icon(bitmapDescriptor);
                    markerOptions.snippet(""+item.getPrice());

                    super.onBeforeClusterItemRendered(item, markerOptions);
                }
            });
            mClusterManager.setOnClusterItemInfoWindowClickListener(new ClusterManager.OnClusterItemInfoWindowClickListener<Hotel>() {
                @Override
                public void onClusterItemInfoWindowClick(Hotel i)
                {
                    getActivity().finish();
//                    Toast.makeText(getActivity(), "Action", Toast.LENGTH_SHORT).show();
                }
            });
//            mMap.setOnCameraMoveCanceledListener(m);
            //setOnCameraChangeListener(mClusterManager);
            mMap.setOnInfoWindowClickListener(mClusterManager);
            renderView();
        }
    }
项目:civify-app    文件:IssueMarker.java   
@NonNull
public final IssueMarker setIcon(@DrawableRes int markerIcon) {
    checkRendered();
    setIcon(markerIcon, new IconCallback() {
        @Override
        public void setIcon(@NonNull BitmapDescriptor icon) {
            mMarker.setIcon(icon);
            Log.d(TAG, "Icon set to marker");
        }
    });
    return this;
}
项目:civify-app    文件:IssueMarker.java   
@NonNull
private IssueMarker setIcon(@DrawableRes int markerIcon, final MarkerOptions options) {
    setIcon(markerIcon, new IconCallback() {
        @Override
        public void setIcon(@NonNull BitmapDescriptor icon) {
            options.icon(icon);
        }
    });
    return this;
}
项目:SpaceRace    文件:MapActivity.java   
@NonNull
private Marker placeMarker(@NonNull BitmapDescriptor draw, @NonNull LatLng pos) {
    if (marker == null) {

        return map.addMarker(new MarkerOptions()
                .position(pos)
                .icon(draw));
    } else {

        marker.setPosition(pos);
        return marker;
    }
}
项目:SpaceRace    文件:MapActivity.java   
@NonNull
private Marker placeMarker(@NonNull BitmapDescriptor draw, @NonNull Location pos) {
    return placeMarker(draw, new LatLng(
            pos.getLatitude(),
            pos.getLongitude()
    ));
}
项目:SpaceRace    文件:PiecePicker.java   
@NonNull
public static BitmapDescriptor getPiece(@NonNull PieceShape shape, int id) {

    Bitmap toScale = BitmapFactory.decodeResource(SpaceRace.getAppContext().getResources(), id);
    toScale = Bitmap.createScaledBitmap(toScale, shape.getWidth(), shape.getLength(), false);

    return BitmapDescriptorFactory.fromBitmap(toScale);
}
项目:SpaceRace    文件:PathDrawer.java   
private PathDrawer(GoogleMap map,
                   Deque<PathCreator.DistanceFrom> path,
                   BitmapDescriptor firstNodeIcon,
                   BitmapDescriptor middleNodeIcon,
                   BitmapDescriptor lastNodeIcon) {

    this.map = map;
    this.path = new ArrayDeque<>();
    this.path.addAll(path);
    last = path.getFirst();
    this.firstNodeIcon = firstNodeIcon;
    this.middleNodeIcon = middleNodeIcon;
    this.lastNodeIcon = lastNodeIcon;
    this.isFirstPop = true;
}