/** * Sets the color for a marker * * @param color Color for a marker */ /* package */ void setMarkerColor(String color) { int integerColor = Color.parseColor("#" + convertColor(color)); mMarkerColor = getHueValue(integerColor); mMarkerOptions.icon(BitmapDescriptorFactory.defaultMarker(mMarkerColor)); mStylesSet.add("markerColor"); }
private void addMarker(GoogleMap map, double lat, double lon, int title, int snippet, int hue) { map.addMarker(new MarkerOptions().position(new LatLng(lat, lon)) .title(getString(title)) .snippet(getString(snippet)) .icon(BitmapDescriptorFactory.defaultMarker(hue))); } }
private void placeMarkers() { // Add a marker for every earthquake for (EarthQuakeRec rec : mRetainedFragment.getData()) { // Add a new marker for this earthquake mMap.addMarker(new MarkerOptions() // Set the Marker's position .position(new LatLng(rec.getLat(), rec.getLng())) // Set the title of the Marker's information window .title(String.valueOf(rec.getMagnitude())) // Set the color for the Marker .icon(BitmapDescriptorFactory .defaultMarker(getMarkerColor(rec .getMagnitude())))); } }
/** * 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); } } }
public void testIcon() throws Exception { BitmapDescriptor icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN); pointStyle .setIcon(icon); assertEquals(icon, pointStyle.getIcon()); assertEquals(icon, pointStyle.toMarkerOptions().getIcon()); }
/** * Creates a new marker option from given properties of an existing marker option * * @param originalMarkerOption An existing MarkerOption instance * @param iconRandomColorMode True if marker color mode is random, false otherwise * @param markerColor Color of the marker * @return A new MarkerOption */ private static MarkerOptions createMarkerOptions(MarkerOptions originalMarkerOption, boolean iconRandomColorMode, float markerColor) { MarkerOptions newMarkerOption = new MarkerOptions(); newMarkerOption.rotation(originalMarkerOption.getRotation()); newMarkerOption.anchor(originalMarkerOption.getAnchorU(), originalMarkerOption.getAnchorV()); if (iconRandomColorMode) { float hue = getHueValue(computeRandomColor((int) markerColor)); originalMarkerOption.icon(BitmapDescriptorFactory.defaultMarker(hue)); } newMarkerOption.icon(originalMarkerOption.getIcon()); return newMarkerOption; }
@Override public boolean onMarkerClick(Marker marker) { float newHue = MARKER_HUES[new Random().nextInt(MARKER_HUES.length)]; mMarkerInfo.mHue = newHue; marker.setIcon(BitmapDescriptorFactory.defaultMarker(newHue)); return true; }
private void addMarker(LatLng destination) { MarkerOptions options = new MarkerOptions(); options.position(destination); options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); mMap.addMarker(options); }
} else if (marker.equals(mAdelaide)) { marker.setIcon(BitmapDescriptorFactory.defaultMarker(mRandom.nextFloat() * 360)); marker.setAlpha(mRandom.nextFloat());
/** * Add Markers with default info windows to the map. */ private void addMarkers() { mMap.addMarker(new MarkerOptions() .position(BRISBANE) .title("Brisbane")); mMap.addMarker(new MarkerOptions() .position(MELBOURNE) .title("Melbourne") .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); mMap.addMarker(new MarkerOptions() .position(SYDNEY) .title("Sydney") .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED))); mMap.addMarker(new MarkerOptions() .position(ADELAIDE) .title("Adelaide") .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW))); mMap.addMarker(new MarkerOptions() .position(PERTH) .title("Perth") .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA))); } }
@Override public void onMapReady(GoogleMap map) { MarkerOptions markerOptions = new MarkerOptions() .position(mMarkerPosition) .icon(BitmapDescriptorFactory.defaultMarker(mMarkerInfo.mHue)) .draggable(true); map.addMarker(markerOptions); map.setOnMarkerDragListener(this); map.setOnMarkerClickListener(this); if (mMoveCameraToMarker) { map.animateCamera(CameraUpdateFactory.newLatLng(mMarkerPosition)); } }
public DraggableCircle(LatLng center, double radiusMeters) { mRadiusMeters = radiusMeters; mCenterMarker = mMap.addMarker(new MarkerOptions() .position(center) .draggable(true)); mRadiusMarker = mMap.addMarker(new MarkerOptions() .position(toRadiusLatLng(center, radiusMeters)) .draggable(true) .icon(BitmapDescriptorFactory.defaultMarker( BitmapDescriptorFactory.HUE_AZURE))); mCircle = mMap.addCircle(new CircleOptions() .center(center) .radius(radiusMeters) .strokeWidth(mStrokeWidthBar.getProgress()) .strokeColor(mStrokeColorArgb) .fillColor(mFillColorArgb) .clickable(mClickabilityCheckbox.isChecked())); }
private void resetMarkers() { for (Marker marker : this.markers) { marker.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)); } }
.title("Brisbane") .snippet("Population: 2,074,200") .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); 135 - 10 * Math.cos(i * Math.PI / (numMarkersInRainbow - 1)))) .title("Marker " + i) .icon(BitmapDescriptorFactory.defaultMarker(i * 360 / numMarkersInRainbow)) .flat(flat) .rotation(rotation));
/** * Sets the color for a marker * * @param color Color for a marker */ /* package */ void setMarkerColor(String color) { int integerColor = Color.parseColor("#" + convertColor(color)); mMarkerColor = getHueValue(integerColor); mMarkerOptions.icon(BitmapDescriptorFactory.defaultMarker(mMarkerColor)); mStylesSet.add("markerColor"); }
@Override public ClusterOptions getClusterOptions(List<Marker> markers) { float hue; if (markers.get(0).getClusterGroup() == DYNAMIC_GROUP) { hue = BitmapDescriptorFactory.HUE_ORANGE; } else { hue = BitmapDescriptorFactory.HUE_ROSE; } BitmapDescriptor blueIcon = BitmapDescriptorFactory.defaultMarker(hue); return new ClusterOptions().icon(blueIcon); } }));
@Override public void onMapLongClick(LatLng latLng) { String snippet = String.format(Locale.getDefault(), getString(R.string.lat_long_snippet), latLng.latitude, latLng.longitude); map.addMarker(new MarkerOptions() .position(latLng) .title(getString(R.string.dropped_pin)) .snippet(snippet) .icon(BitmapDescriptorFactory.defaultMarker (BitmapDescriptorFactory.HUE_BLUE))); } });
@Override public void onMapLongClick(LatLng position) { BitmapDescriptor yellowIcon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW); map.addMarker(new MarkerOptions().position(position).icon(yellowIcon).clusterGroup(DYNAMIC_GROUP)); } });
/** * Callback for receiving locations. * This is where location updates can be handled by moving markers or the camera. */ public void onLocationChanged(IALocation location) { LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); if (mMarker == null) { if (mMap != null) { mMarker = mMap.addMarker(new MarkerOptions().position(latLng) .icon(BitmapDescriptorFactory.defaultMarker(HUE_IABLUE))); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 17.0f)); } } else { mMarker.setPosition(latLng); } }
@Override public void onMapReady(GoogleMap googleMap) { double latitude = Double.valueOf(obj.getGeometry().getLocation().getLat()); double longitude = Double.valueOf(obj.getGeometry().getLocation().getLng()); MarkerOptions marker = new MarkerOptions().position( new LatLng(latitude, longitude)).title(obj.getName()); // Changing marker icon marker.icon(BitmapDescriptorFactory .defaultMarker(BitmapDescriptorFactory.HUE_ROSE)); // Perform any camera updates here Marker marker1 = googleMap.addMarker(marker); marker1.showInfoWindow(); CameraPosition cameraPosition = new CameraPosition.Builder() .target(new LatLng(latitude, longitude)).zoom(15).build(); googleMap.animateCamera(CameraUpdateFactory .newCameraPosition(cameraPosition)); googleMap.getUiSettings().setZoomControlsEnabled(true); googleMap.getUiSettings().setZoomGesturesEnabled(true); PlaceSearchItemMapFragment.this.googleMap = googleMap; } });