com.google.android.gms.maps.model.BitmapDescriptorFactory Java Examples

The following examples show how to use com.google.android.gms.maps.model.BitmapDescriptorFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapActivity.java    From homeassist with Apache License 2.0 6 votes vote down vote up
private Marker createMarker(Entity device) {
    Marker marker;
    LatLng latLng = device.getLocation();
    if (device.hasMdiIcon()) {
        marker = mMap.addMarker(new MarkerOptions()
                .icon(BitmapDescriptorFactory.fromBitmap(mifMarkerIcon.makeMaterialIcon(device.getMdiIcon())))
                .position(latLng)
                .zIndex(2.0f)
                .anchor(mifMarkerIcon.getAnchorU(), mifMarkerIcon.getAnchorV()));
    } else {
        marker = mMap.addMarker(new MarkerOptions()
                .icon(BitmapDescriptorFactory.fromBitmap(mifMarkerText.makeIcon(device.getFriendlyName())))
                .position(latLng)
                .zIndex(2.0f)
                .anchor(mifMarkerText.getAnchorU(), mifMarkerText.getAnchorV()));
    }

    return marker;
}
 
Example #2
Source File: MovingMarkerActivity.java    From Airbnb-Android-Google-Map-View with MIT License 6 votes vote down vote up
/**
   * Highlight the marker by marker.
   */
  private void highLightMarker(Marker marker) {

/*
      for (Marker foundMarker : this.markers) {
	if (!foundMarker.equals(marker)) {
		foundMarker.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
	} else {
		foundMarker.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
		foundMarker.showInfoWindow();
	}
}
*/
      marker.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
      //  marker.showInfoWindow();
      //marker.remove();
      //Utils.bounceMarker(googleMap, marker);

      this.selectedMarker = marker;
  }
 
Example #3
Source File: Maps.java    From aware with MIT License 6 votes vote down vote up
/**
 * Sets marker at given location on map
 *
 * @param LocationLat  latitude
 * @param LocationLong longitude
 * @param LocationName name of location
 * @param LocationIcon icon
 */
public void ShowMarker(Double LocationLat, Double LocationLong, String LocationName, Integer LocationIcon) {
    LatLng Coord = new LatLng(LocationLat, LocationLong);

    if (ContextCompat.checkSelfPermission(activity,
            Manifest.permission.ACCESS_COARSE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        if (map != null) {
            map.setMyLocationEnabled(true);
            map.moveCamera(CameraUpdateFactory.newLatLngZoom(Coord, 10));

            MarkerOptions abc = new MarkerOptions();
            MarkerOptions x = abc
                    .title(LocationName)
                    .position(Coord)
                    .icon(BitmapDescriptorFactory.fromResource(LocationIcon));
            map.addMarker(x);

        }
    }
}
 
Example #4
Source File: MainActivity.java    From AndroidLocationStarterKit with MIT License 6 votes vote down vote up
private void drawUserPositionMarker(Location location){
    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());

    if(this.userPositionMarkerBitmapDescriptor == null){
        userPositionMarkerBitmapDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.user_position_point);
    }

    if (userPositionMarker == null) {
        userPositionMarker = map.addMarker(new MarkerOptions()
                .position(latLng)
                .flat(true)
                .anchor(0.5f, 0.5f)
                .icon(this.userPositionMarkerBitmapDescriptor));
    } else {
        userPositionMarker.setPosition(latLng);
    }
}
 
Example #5
Source File: PlacesDisplayTask.java    From Crimson with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPostExecute(List<HashMap<String, String>> list) {
    googleMap.clear();

        for (int i = 0; i < list.size(); i++) {
            MarkerOptions markerOptions = new MarkerOptions();
            HashMap<String, String> googlePlace = list.get(i);
            double lat = Double.parseDouble(googlePlace.get("lat"));
            double lng = Double.parseDouble(googlePlace.get("lng"));
            String placeName = googlePlace.get("place_name");
            //String vicinity = googlePlace.get("vicinity");
            LatLng latLng = new LatLng(lat, lng);
            markerOptions.position(latLng);
            markerOptions.title(placeName);
            markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.custom_marker));
            googleMap.addMarker(markerOptions);
        }
    }
 
Example #6
Source File: StyleUtils.java    From geopackage-android-map with MIT License 6 votes vote down vote up
/**
 * Set the icon into the marker options
 *
 * @param markerOptions marker options
 * @param icon          icon row
 * @param density       display density: {@link android.util.DisplayMetrics#density}
 * @param iconCache     icon cache
 * @return true if icon was set into the marker options
 */
public static boolean setIcon(MarkerOptions markerOptions, IconRow icon, float density, IconCache iconCache) {

    boolean iconSet = false;

    if (icon != null) {

        Bitmap iconImage = createIcon(icon, density, iconCache);
        markerOptions.icon(BitmapDescriptorFactory
                .fromBitmap(iconImage));
        iconSet = true;

        double anchorU = icon.getAnchorUOrDefault();
        double anchorV = icon.getAnchorVOrDefault();

        markerOptions.anchor((float) anchorU, (float) anchorV);
    }

    return iconSet;
}
 
Example #7
Source File: BusinessDetailsActivity.java    From YelpQL with MIT License 6 votes vote down vote up
private void showPointerOnMap(final double latitude, final double longitude) {
    mvRestaurantLocation.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap googleMap) {
            LatLng latLng = new LatLng(latitude, longitude);
            googleMap.addMarker(new MarkerOptions()
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_flag))
                    .anchor(0.0f, 1.0f)
                    .position(latLng));
            googleMap.getUiSettings().setMyLocationButtonEnabled(false);
            googleMap.getUiSettings().setZoomControlsEnabled(true);

            // Updates the location and zoom of the MapView
            CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 15);
            googleMap.moveCamera(cameraUpdate);
        }
    });
}
 
Example #8
Source File: MapWrapper.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override
public void addMarker(final Marker aMarker) {
	final MarkerOptions marker = new MarkerOptions();
	marker.position(new LatLng(aMarker.latitude, aMarker.longitude));
	if (!TextUtils.isEmpty(aMarker.title)) {
		marker.title(aMarker.title);
	}
	if (!TextUtils.isEmpty(aMarker.snippet)) {
		marker.snippet(aMarker.snippet);
	}
	if (aMarker.bitmap != null) {
		marker.icon(BitmapDescriptorFactory.fromBitmap(aMarker.bitmap));
	} else {
		if (aMarker.icon != 0) {
			marker.icon(BitmapDescriptorFactory.fromResource(aMarker.icon));
		}
	}
	if (aMarker.anchor == Marker.Anchor.CENTER) {
		marker.anchor(0.5f, 0.5f);
	}
	mGoogleMap.addMarker(marker);
}
 
Example #9
Source File: Venue.java    From mConference-Framework with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected void onPostExecute(Void aVoid) {
    if (status == ConnectionResult.SUCCESS) {
        // create marker
        MarkerOptions marker = new MarkerOptions().position(
                new LatLng(latitude, longitude)).title(venueAddress);

        // Changing marker icon
        marker.icon(BitmapDescriptorFactory
                .defaultMarker(BitmapDescriptorFactory.HUE_ROSE));

        // adding marker
        googleMap.addMarker(marker);
        CameraPosition cameraPosition = new CameraPosition.Builder()
                .target(new LatLng(latitude, longitude)).zoom(12).build();
        googleMap.animateCamera(CameraUpdateFactory
                .newCameraPosition(cameraPosition));
    } else {
        DialogFragment dialogFragment = new PlayServicesUnavailableDialogFragment();
        dialogFragment.show(getActivity().getFragmentManager(), "Play Service Problem");
    }
}
 
Example #10
Source File: ViewUtils.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #11
Source File: VPNFragment.java    From android with GNU General Public License v3.0 6 votes vote down vote up
private void updateMapLocation() {
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (mMap != null && mCurrentLocation != null) {
                mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mCurrentLocation, 5));
                if (mCurrentPosMarker == null) {
                    mCurrentPosMarker = mMap.addMarker(new MarkerOptions().position(mCurrentLocation).icon(BitmapDescriptorFactory.fromResource(R.drawable.current_location)));
                } else {
                    mCurrentPosMarker.setPosition(mCurrentLocation);
                    mCurrentPosMarker.setVisible(true);
                }
            }
        }
    });
}
 
Example #12
Source File: MosquesActivity.java    From MuslimMateAndroid with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onLocationChanged(Location location) {
    if (location.getLatitude() != 0 || location.getLongitude() != 0) {
        setFusedLatitude(location.getLatitude());
        setFusedLongitude(location.getLongitude());
        stopFusedLocation();
        CameraPosition oldPos = googleMap.getCameraPosition();
        CameraPosition pos = CameraPosition.builder(oldPos)
                .target(getPosition())
                .zoom(zoom)
                .build();
        googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(pos));

        Marker marker = googleMap.addMarker(new MarkerOptions()
                .position(getPosition())
                .title("My Location").icon(BitmapDescriptorFactory.fromResource(R.drawable.placeholder)));


        AsyncTask placesAsync = new Places().execute(getPosition());

    }

}
 
Example #13
Source File: PlaceMapFragment.java    From RxGpsService with Apache License 2.0 6 votes vote down vote up
private Target getTargetForPois(final Place place, final int idPlaceToGo) {
    return new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            bitmap = bitmapHelper.getTintedBitmap(bitmap, ContextCompat.getColor(getContext(), R.color.orange));
            bitmap = bitmapHelper.getScaledBitmap(bitmap, (int) getResources().getDimension(R.dimen._30dp));
            markersMap.put(addMarkerPoi(place, BitmapDescriptorFactory.fromBitmap(bitmap), idPlaceToGo), place);
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {
            markersMap.put(addMarkerPoi(place, getIconPoi(), idPlaceToGo), place);
        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {

        }
    };
}
 
Example #14
Source File: DriverTracking.java    From UberClone with MIT License 6 votes vote down vote up
private void displayLocation(){
    //add driver location
    if(driverMarker!=null)driverMarker.remove();
    driverMarker=mMap.addMarker(new MarkerOptions().position(new LatLng(Common.currentLat, Common.currentLng))
    .title("You").icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_marker)));
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(Common.currentLat, Common.currentLng), 14f));
    geoFire.setLocation(Common.userID,
            new GeoLocation(Common.currentLat, Common.currentLng),
            new GeoFire.CompletionListener() {
                @Override
                public void onComplete(String key, DatabaseError error) {

                }
            });
    //remove route
    if(direction!=null)direction.remove();
      getDirection();

}
 
Example #15
Source File: Home.java    From UberClone with MIT License 6 votes vote down vote up
private void requestPickup(String uid) {
    DatabaseReference dbRequest=FirebaseDatabase.getInstance().getReference(Common.pickup_request_tbl);
    GeoFire mGeofire=new GeoFire(dbRequest);
    mGeofire.setLocation(uid, new GeoLocation(Common.currenLocation.latitude, Common.currenLocation.longitude),
            new GeoFire.CompletionListener() {
                @Override
                public void onComplete(String key, DatabaseError error) {

                }
            });
    if (riderMarket.isVisible())riderMarket.remove();
    riderMarket=mMap.addMarker(new MarkerOptions().title(getResources().getString(R.string.pickup_here)).snippet("").position(new LatLng(Common.currenLocation.latitude, Common.currenLocation.longitude))
            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
    riderMarket.showInfoWindow();
    btnRequestPickup.setText(getResources().getString(R.string.getting_uber));
    findDriver();
}
 
Example #16
Source File: SaveStateDemoActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState == null) {
        // Activity created for the first time.
        mMarkerPosition = DEFAULT_MARKER_POSITION;
        mMarkerInfo = new MarkerInfo(BitmapDescriptorFactory.HUE_RED);
        mMoveCameraToMarker = true;
    } else {
        // Extract the state of the MapFragment:
        // - Objects from the API (eg. LatLng, MarkerOptions, etc.) were stored directly in
        //   the savedInsanceState Bundle.
        // - Custom Parcelable objects were wrapped in another Bundle.

        mMarkerPosition = savedInstanceState.getParcelable(MARKER_POSITION);

        Bundle bundle = savedInstanceState.getBundle(OTHER_OPTIONS);
        mMarkerInfo = bundle.getParcelable(MARKER_INFO);

        mMoveCameraToMarker = false;
    }

    getMapAsync(this);
}
 
Example #17
Source File: Home.java    From Taxi-App-Android-XML with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    boolean success = googleMap.setMapStyle(new MapStyleOptions(getResources()
            .getString(R.string.style_json)));

    if (!success) {
        Log.e("Style", "Style parsing failed.");
    }
    LatLng jakarta = new LatLng(-6.232812, 106.820933);
    LatLng southjakarta = new LatLng(-6.22865,106.8151753);
    mMap.addMarker(new MarkerOptions().position(jakarta).icon(BitmapDescriptorFactory.fromBitmap(getBitmapFromView("Set Pickup Location", R.drawable.dot_pickup))));
    mMap.addMarker(new MarkerOptions().position(southjakarta).icon(BitmapDescriptorFactory.fromBitmap(getBitmapFromView("Set Dropoff Location", R.drawable.dot_dropoff))));
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(jakarta, 15f));


}
 
Example #18
Source File: EstablishmentInteractorImpl.java    From Saude-no-Mapa with MIT License 6 votes vote down vote up
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;
}
 
Example #19
Source File: MapOverlay.java    From mytracks with Apache License 2.0 6 votes vote down vote up
/**
 * Updates the waypoints.
 * 
 * @param googleMap the google map.
 */
private void updateWaypoints(GoogleMap googleMap) {
  synchronized (waypoints) {
    for (Waypoint waypoint : waypoints) {
      Location location = waypoint.getLocation();
      LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
      int drawableId = waypoint.getType() == WaypointType.STATISTICS 
          ? R.drawable.ic_marker_yellow_pushpin : R.drawable.ic_marker_blue_pushpin;
      MarkerOptions markerOptions = new MarkerOptions().position(latLng)
          .anchor(WAYPOINT_X_ANCHOR, WAYPOINT_Y_ANCHOR).draggable(false).visible(true)
          .icon(BitmapDescriptorFactory.fromResource(drawableId))
          .title(String.valueOf(waypoint.getId()));
      googleMap.addMarker(markerOptions);
    }
  }
}
 
Example #20
Source File: MainActivity.java    From NYU-BusTracker-Android with Apache License 2.0 6 votes vote down vote up
private void updateMapWithNewBusLocations() {
    if (startStop == null || endStop == null) {
        mMap.clear();
        displayStopError();
        return;
    }
    List<Route> routesBetweenStartAndEnd = startStop.getRoutesTo(endStop);
    BusManager sharedManager = BusManager.getBusManager();
    for (Marker m : busesOnMap) {
        m.remove();
    }
    busesOnMap = new ArrayList<>();
    if (clickableMapMarkers == null)
        clickableMapMarkers = new HashMap<>();  // New set of buses means new set of clickable markers!
    for (Route r : routesBetweenStartAndEnd) {
        for (Bus b : sharedManager.getBuses()) {
            //if (BuildConfig.DEBUG) Log.v("BusLocations", "bus id: " + b.getID() + ", bus route: " + b.getRoute() + " vs route: " + r.getID());
            if (b.getRoute().equals(r.getID())) {
                Marker mMarker = mMap.addMarker(new MarkerOptions().position(b.getLocation()).icon(BitmapDescriptorFactory.fromBitmap(rotateBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.ic_bus_arrow), b.getHeading()))).anchor(0.5f, 0.5f));
                clickableMapMarkers.put(mMarker.getId(), false);    // Unable to click on buses.
                busesOnMap.add(mMarker);
            }
        }
    }
}
 
Example #21
Source File: AddMapActivity.java    From JalanJalan with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public void onConnected(Bundle bundle) {
    if (location == null) {
        // get last location device
        location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
        if (mMap != null) {
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 13));
            mMap.addMarker(new MarkerOptions()
                            .position(new LatLng(location.getLatitude(), location.getLongitude()))
                            .title("Starting Point")
                            .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_marker))
            );
            lat = location.getLatitude();
            lng = location.getLongitude();

            Toast.makeText(this, "Lokasi kamu saat ini, sebagai patokan titik awal perjalanan kamu kak :')", Toast.LENGTH_LONG).show();
        }
    }

}
 
Example #22
Source File: MapMarker.java    From android-app with GNU General Public License v2.0 6 votes vote down vote up
private BitmapDescriptor getIcon(Date data) {
    DateTime current = new DateTime(Calendar.getInstance());
    DateTime last = new DateTime(data);
    int diff =  Minutes.minutesBetween(last, current).getMinutes();

    BitmapDescriptor bitmap;

    if(diff >= 5 && diff < 10 ) {
        bitmap = BitmapDescriptorFactory
                .fromResource(R.drawable.bus_yellow);
    }  else if(diff >= 10 ) {
       bitmap = BitmapDescriptorFactory
            .fromResource(R.drawable.bus_red);
    } else {
        bitmap = BitmapDescriptorFactory
                .fromResource(R.drawable.bus_green);
    }
    return bitmap;
}
 
Example #23
Source File: MarkerActivity.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 6 votes vote down vote up
private void addMarkersToMap()
{
	MarkerOptions options =new MarkerOptions();
	options.position(BRISBANE);
	options.title("brisbane");
	options.snippet("Population: 2,544,634");
	options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
	options.draggable(true);
	CustomInfoWindowAdapter.brisbane=googleMap.addMarker(options);


	MarkerOptions options2 =new MarkerOptions();
	options2.position(ADELAIDE);
	options2.title("adelaide");
	options2.snippet("Population: 3,543,222");
	Drawable drawable=ContextCompat.getDrawable(getApplicationContext(),R.drawable.ic_person_pin_circle_black_24dp);
	options2.icon(convertDrawableToBitmap(drawable));
	options2.draggable(true);
	CustomInfoWindowAdapter.adelaide=googleMap.addMarker(options2);
}
 
Example #24
Source File: KaabaLocatorFragment.java    From PrayTime-Android with Apache License 2.0 5 votes vote down vote up
private void initMap() {
  if (mMap == null && mLastLocation == null) {
    Log.w("KabaaLocatorFragment", "Ignoring since mMap or mLastLocation is null");
    return;
  }

  registerRotationListener();

  LatLng startPosition = new LatLng(mLastLocation.getLatitude(), mLastLocation.getLongitude());
  //21.4224698,39.8262066
  LatLng kaaba = new LatLng(21.4224698, 39.8262066);

  mMap.setMyLocationEnabled(true);
  mMap.getUiSettings().setMyLocationButtonEnabled(true);
  mMap.getUiSettings().setCompassEnabled(false);
  mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(startPosition, 13));
  //mMap.getUiSettings().setRotateGesturesEnabled(false);

  mMap.clear();

  mMap.addMarker(new MarkerOptions()
      .title(getString(R.string.kaaba))
      .position(kaaba));

  mMap.addMarker(new MarkerOptions()
      .icon(BitmapDescriptorFactory.fromResource(R.drawable.compass))
      .title(getString(R.string.current_location))
      .position(startPosition));

  // Polylines are useful for marking paths and routes on the map.
  mMap.addPolyline(new PolylineOptions().geodesic(true)
      .add(startPosition)  // user position
      .add(kaaba)
      .color(Color.RED));  // Kaabah

}
 
Example #25
Source File: DefaultClusterRenderer.java    From android-maps-utils with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a BitmapDescriptor for the given cluster that contains a rough count of the number of
 * items. Used to set the cluster marker icon in the default implementations of
 * {@link #onBeforeClusterRendered(Cluster, MarkerOptions)} and
 * {@link #onClusterUpdated(Cluster, Marker)}.
 *
 * @param cluster cluster to get BitmapDescriptor for
 * @return a BitmapDescriptor for the marker icon for the given cluster that contains a rough
 * count of the number of items.
 */
@NonNull
protected BitmapDescriptor getDescriptorForCluster(@NonNull Cluster<T> cluster) {
    int bucket = getBucket(cluster);
    BitmapDescriptor descriptor = mIcons.get(bucket);
    if (descriptor == null) {
        mColoredCircleBackground.getPaint().setColor(getColor(bucket));
        descriptor = BitmapDescriptorFactory.fromBitmap(mIconGenerator.makeIcon(getClusterText(bucket)));
        mIcons.put(bucket, descriptor);
    }
    return descriptor;
}
 
Example #26
Source File: LocationActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private LiveLocation addUserMarker(TLRPC.TL_channelLocation location) {
    LatLng latLng = new LatLng(location.geo_point.lat, location.geo_point._long);
    LiveLocation liveLocation = new LiveLocation();
    int did = (int) dialogId;
    if (did > 0) {
        liveLocation.user = getMessagesController().getUser(did);
        liveLocation.id = did;
    } else {
        liveLocation.chat = getMessagesController().getChat(-did);
        liveLocation.id = did;
    }

    try {
        MarkerOptions options = new MarkerOptions().position(latLng);
        Bitmap bitmap = createUserBitmap(liveLocation);
        if (bitmap != null) {
            options.icon(BitmapDescriptorFactory.fromBitmap(bitmap));
            options.anchor(0.5f, 0.907f);
            liveLocation.marker = googleMap.addMarker(options);
            markers.add(liveLocation);
            markersMap.put(liveLocation.id, liveLocation);
        }
    } catch (Exception e) {
        FileLog.e(e);
    }

    return liveLocation;
}
 
Example #27
Source File: MapFragment.java    From Android-GoogleMaps-Part1 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void drawOverlay( LatLng location, int width, int height ) {
    GroundOverlayOptions options = new GroundOverlayOptions();
    options.position(location, width, height);

    options.image( BitmapDescriptorFactory
            .fromBitmap( BitmapFactory
                .decodeResource( getResources(), R.mipmap.ic_launcher ) ) );
    getMap().addGroundOverlay(options);
}
 
Example #28
Source File: BaseNiboFragment.java    From Nibo with MIT License 5 votes vote down vote up
public void addOverlay(LatLng place) {
    GroundOverlay groundOverlay = mMap.addGroundOverlay(new
            GroundOverlayOptions()
            .position(place, 100)
            .transparency(0.5f)
            .zIndex(3)
            .image(BitmapDescriptorFactory.fromBitmap(drawableToBitmap(getActivity().getResources().getDrawable(R.drawable.map_overlay)))));

    startOverlayAnimation(groundOverlay);
}
 
Example #29
Source File: RecommendedRouteFragment.java    From rox-android with Apache License 2.0 5 votes vote down vote up
private void showCurrentLocationInMap() {
    Location currentLocation = getCurrentLocationArg();
    LatLng latLng = new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
    googleMap.addMarker(new MarkerOptions()
            .position(latLng)
            .title(getString(R.string.current_location))
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_map_location)));
    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 13f));
}
 
Example #30
Source File: EditCameraLocationActivity.java    From evercam-android with GNU Affero General Public License v3.0 5 votes vote down vote up
public void addMapTapListner() {
    mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
        @Override
        public void onMapClick(LatLng latLng) {
            Log.v("Lat and Lng", "" + latLng.toString());
            mMap.clear();
            tappedLatLng = latLng;
            mMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));

            new CallMashapeAsync().execute();
        }
    });
}