public Builder<T> anchor(float u, float v) { markerOptions.anchor(u, v); return this; }
/** * Sets the hotspot / anchor point of a marker * * @param x x point of a marker position * @param y y point of a marker position * @param xUnits units in which the x value is specified * @param yUnits units in which the y value is specified */ public void setMarkerHotSpot(float x, float y, String xUnits, String yUnits) { float xAnchor = 0.5f; float yAnchor = 1.0f; // Set x coordinate if (xUnits.equals("fraction")) { xAnchor = x; } if (yUnits.equals("fraction")) { yAnchor = y; } mMarkerOptions.anchor(xAnchor, yAnchor); }
private void addIcon(IconGenerator iconFactory, CharSequence text, LatLng position) { MarkerOptions markerOptions = new MarkerOptions(). icon(BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon(text))). position(position). anchor(iconFactory.getAnchorU(), iconFactory.getAnchorV()); getMap().addMarker(markerOptions); }
/** * 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; }
/** * Sets the inline point style by copying over the styles that have been set * * @param markerOptions marker options object to add inline styles to * @param inlineStyle inline styles to apply * @param markerUrlIconUrl default marker icon URL from shared style */ private void setInlinePointStyle(MarkerOptions markerOptions, KmlStyle inlineStyle, String markerUrlIconUrl) { MarkerOptions inlineMarkerOptions = inlineStyle.getMarkerOptions(); if (inlineStyle.isStyleSet("heading")) { markerOptions.rotation(inlineMarkerOptions.getRotation()); } if (inlineStyle.isStyleSet("hotSpot")) { markerOptions .anchor(inlineMarkerOptions.getAnchorU(), inlineMarkerOptions.getAnchorV()); } if (inlineStyle.isStyleSet("markerColor")) { markerOptions.icon(inlineMarkerOptions.getIcon()); } if (inlineStyle.isStyleSet("iconUrl")) { addMarkerIcons(inlineStyle.getIconUrl(), markerOptions); } else if (markerUrlIconUrl != null) { // Inline style with no icon defined addMarkerIcons(markerUrlIconUrl, markerOptions); } }
/** * Gets a new MarkerOptions object containing styles for the GeoJsonPoint * * @return new MarkerOptions object */ public MarkerOptions toMarkerOptions() { MarkerOptions markerOptions = new MarkerOptions(); markerOptions.alpha(mMarkerOptions.getAlpha()); markerOptions.anchor(mMarkerOptions.getAnchorU(), mMarkerOptions.getAnchorV()); markerOptions.draggable(mMarkerOptions.isDraggable()); markerOptions.flat(mMarkerOptions.isFlat()); markerOptions.icon(mMarkerOptions.getIcon()); markerOptions.infoWindowAnchor(mMarkerOptions.getInfoWindowAnchorU(), mMarkerOptions.getInfoWindowAnchorV()); markerOptions.rotation(mMarkerOptions.getRotation()); markerOptions.snippet(mMarkerOptions.getSnippet()); markerOptions.title(mMarkerOptions.getTitle()); markerOptions.visible(mMarkerOptions.isVisible()); markerOptions.zIndex(mMarkerOptions.getZIndex()); return markerOptions; }
public MarkerOptions anchor(float u, float v) { real.anchor(u, v); return this; }
public void setAnchor(float anchorU, float anchorV) { if (marker != null) { marker.setAnchor(anchorU, anchorV); } else { markerOptions.anchor(anchorU, anchorV); } }
/** * Sets the hotspot / anchor point of a marker * * @param x x point of a marker position * @param y y point of a marker position * @param xUnits units in which the x value is specified * @param yUnits units in which the y value is specified */ /* package */ void setHotSpot(float x, float y, String xUnits, String yUnits) { float xAnchor = 0.5f; float yAnchor = 1.0f; // Set x coordinate if (xUnits.equals("fraction")) { xAnchor = x; } if (yUnits.equals("fraction")) { yAnchor = y; } mMarkerOptions.anchor(xAnchor, yAnchor); mStylesSet.add("hotSpot"); }
/** * Sets the Anchor U and V coordinates of the GeoJsonPoint. The anchor point is specified in * the * continuous space [0.0, 1.0] x [0.0, 1.0], where (0, 0) is the top-left corner of the image, * and (1, 1) is the bottom-right corner. The U & V values are the same U & V values * used in * {@link com.google.android.gms.maps.model.MarkerOptions#anchor(float, float)} ()}. * * @param anchorU Anchor U coordinate of the GeoJsonPoint * @param anchorV Anchor V coordinate of the GeoJsonPoint */ public void setAnchor(float anchorU, float anchorV) { mMarkerOptions.anchor(anchorU, anchorV); styleChanged(); }
private void drawMalMarkers(ArrayList<Location> locationList, BitmapDescriptor descriptor){ for(Location location : locationList){ LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); Marker marker = map.addMarker(new MarkerOptions() .position(latLng) .flat(true) .anchor(0.5f, 0.5f) .icon(descriptor)); malMarkers.add(marker); } }
@Override public void onMapLongClick(LatLng latLng) { mMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.avion)) .anchor(0.0f, 1.0f) .position(latLng)); } });
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); } }
/** * Draws a marker at the given point. * <p/> * Should be called when the users touches the map and adds an entry to the * stacks * * @param center the point where the user clicked * @return the drawn Polygon */ private Marker drawMarker(final LatLng center) { return mMap.addMarker( new MarkerOptions().position(center).flat(true).anchor(0.5f, 0.5f).icon(marker)); }
@Override public void updateMarker(@Nullable FusedContact contact) { if (contact == null || !contact.hasLocation() || !isMapReady) { Timber.v("unable to update marker. null:%s, location:%s, mapReady:%s",contact == null, contact == null || contact.hasLocation(), isMapReady); return; } Timber.v("updating marker for contact: %s", contact.getId()); Marker m = mMarkers.get(contact.getId()); if (m != null) { m.setPosition(contact.getLatLng()); } else { m = mMap.addMarker(new MarkerOptions().position(contact.getLatLng()).anchor(0.5f, 0.5f).visible(false)); m.setTag(contact.getId()); mMarkers.put(contact.getId(), m); } contactImageProvider.setMarkerAsync(m, contact); }
public void createAllMarkersInvisible() { LatLng northPoleHideout = new LatLng(90.0D, 0.0D); destMarker = map.addMarker(new MarkerOptions().position(northPoleHideout).icon(BitmapDescriptorFactory.fromBitmap(drawableDest))); destMarker.setVisible(false); currentPosition = map.addMarker(new MarkerOptions().position(northPoleHideout) .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_maps_indicator_current_position_ohne)).anchor(0.5f, 0.5f)); currentPosition.setVisible(false); current_position_anim_ohne = map.addMarker(new MarkerOptions().position(northPoleHideout) .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_maps_indicator_current_position_anim_ohne)).anchor(0.5f, 0.5f)); current_position_anim_ohne.setVisible(false); }
@Override public void onMapLongClick(LatLng arg0) { mTracker.send(new HitBuilders.EventBuilder() .setCategory("Action") .setAction("Longpress_GoogleMap") .build()); longpressLocation = arg0; if (longPressMarker != null) { if (longPressMarker.isVisible()) { longPressMarker.remove(); } } longPressMarker = map.addMarker(new MarkerOptions().position(longpressLocation).icon(BitmapDescriptorFactory.fromBitmap(drawableDest)) .anchor(0.5F, 1.0F)); listHandler.sendEmptyMessage(2); } });
/** * 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 com.google.android.gms.maps.model.MarkerOptions map(MarkerOptions input) { LatLng googleLatLng = AnyMapAdapter.adapt(input.getPosition()); return new com.google.android.gms.maps.model.MarkerOptions() .alpha(input.getAlpha()) .position(googleLatLng) .visible(input.isVisible()) .anchor( input.getAnchorU(), input.getAnchorV() ) .icon( ((BitmapDescriptorAdapter) input.getIcon()).wrappedDescriptor ) .zIndex(input.getZ()); }
/** * Gets a new MarkerOptions object containing styles for the GeoJsonPoint * * @return new MarkerOptions object */ public MarkerOptions toMarkerOptions() { MarkerOptions markerOptions = new MarkerOptions(); markerOptions.alpha(mMarkerOptions.getAlpha()); markerOptions.anchor(mMarkerOptions.getAnchorU(), mMarkerOptions.getAnchorV()); markerOptions.draggable(mMarkerOptions.isDraggable()); markerOptions.flat(mMarkerOptions.isFlat()); markerOptions.icon(mMarkerOptions.getIcon()); markerOptions.infoWindowAnchor(mMarkerOptions.getInfoWindowAnchorU(), mMarkerOptions.getInfoWindowAnchorV()); markerOptions.rotation(mMarkerOptions.getRotation()); markerOptions.snippet(mMarkerOptions.getSnippet()); markerOptions.title(mMarkerOptions.getTitle()); markerOptions.visible(mMarkerOptions.isVisible()); return markerOptions; }