public class Marker extends OverlayWithIW
InfoWindow
(a bubble)
Mimics the Marker class from Google Maps Android API v2 as much as possible. Main differences:Modifier and Type | Class and Description |
---|---|
static interface |
Marker.OnMarkerClickListener |
static interface |
Marker.OnMarkerDragListener |
Overlay.Snappable
Modifier and Type | Field and Description |
---|---|
static float |
ANCHOR_BOTTOM
Usual values in the (U,V) coordinates system of the icon image
|
static float |
ANCHOR_CENTER
Usual values in the (U,V) coordinates system of the icon image
|
static float |
ANCHOR_LEFT
Usual values in the (U,V) coordinates system of the icon image
|
static float |
ANCHOR_RIGHT
Usual values in the (U,V) coordinates system of the icon image
|
static float |
ANCHOR_TOP
Usual values in the (U,V) coordinates system of the icon image
|
protected float |
mAlpha |
protected float |
mAnchorU |
protected float |
mAnchorV |
protected float |
mBearing |
protected boolean |
mDraggable |
protected float |
mDragOffsetY |
protected boolean |
mFlat |
protected Drawable |
mIcon |
protected Drawable |
mImage |
protected boolean |
mIsDragged |
protected float |
mIWAnchorU |
protected float |
mIWAnchorV |
protected Marker.OnMarkerClickListener |
mOnMarkerClickListener |
protected Marker.OnMarkerDragListener |
mOnMarkerDragListener |
protected boolean |
mPanToView |
protected GeoPoint |
mPosition |
protected Point |
mPositionPixels |
protected Resources |
mResources |
protected int |
mTextLabelBackgroundColor |
protected int |
mTextLabelFontSize |
protected int |
mTextLabelForegroundColor |
mId, mInfoWindow, mRelatedObject, mSnippet, mSubDescription, mTitle
mBounds, SHADOW_X_SKEW, SHADOW_Y_SCALE
DEFAULT_ZOOMLEVEL_MINIMAP_DIFFERENCE, NOT_SET
Constructor and Description |
---|
Marker(MapView mapView) |
Marker(MapView mapView,
Context resourceProxy) |
Modifier and Type | Method and Description |
---|---|
static void |
cleanDefaults()
Deprecated.
|
void |
draw(Canvas canvas,
Projection pj) |
protected void |
drawAt(Canvas pCanvas,
int pX,
int pY,
float pOrientation)
Optimized drawing
|
float |
getAlpha() |
float |
getDragOffset()
get the offset in millimeters that the marker is moved up while dragging
|
Drawable |
getIcon() |
Drawable |
getImage()
get the image to be shown in the InfoWindow - this is not the marker icon
|
GeoPoint |
getPosition() |
float |
getRotation() |
int |
getTextLabelBackgroundColor()
used for when the icon is explicitly set to null and the title is not, this will
style the rendered text label
|
int |
getTextLabelFontSize()
used for when the icon is explicitly set to null and the title is not, this will
style the rendered text label
|
int |
getTextLabelForegroundColor()
used for when the icon is explicitly set to null and the title is not, this will
style the rendered text label
|
boolean |
hitTest(MotionEvent event,
MapView mapView) |
boolean |
isDisplayed() |
boolean |
isDraggable() |
boolean |
isFlat() |
boolean |
isInfoWindowShown() |
void |
moveToEventPosition(MotionEvent event,
MapView mapView) |
void |
onDetach(MapView mapView)
Null out the static references when the MapView is detached to prevent memory leaks.
|
boolean |
onLongPress(MotionEvent event,
MapView mapView)
By default does nothing (
return false ). |
protected boolean |
onMarkerClickDefault(Marker marker,
MapView mapView)
default behaviour when no click listener is set
|
boolean |
onSingleTapConfirmed(MotionEvent event,
MapView mapView)
By default does nothing (
return false ). |
boolean |
onTouchEvent(MotionEvent event,
MapView mapView)
You can prevent all(!) other Touch-related events from happening!
By default does nothing ( return false ). |
void |
remove(MapView mapView)
Removes this Marker from the MapView.
|
void |
setAlpha(float alpha) |
void |
setAnchor(float anchorU,
float anchorV) |
void |
setDefaultIcon() |
void |
setDraggable(boolean draggable) |
void |
setDragOffset(float mmUp)
set the offset in millimeters that the marker is moved up while dragging
|
void |
setFlat(boolean flat) |
void |
setIcon(Drawable icon)
Sets the icon for the marker.
|
void |
setImage(Drawable image)
set an image to be shown in the InfoWindow - this is not the marker icon
|
void |
setInfoWindow(MarkerInfoWindow infoWindow)
Set the InfoWindow to be used.
|
void |
setInfoWindowAnchor(float anchorU,
float anchorV) |
void |
setOnMarkerClickListener(Marker.OnMarkerClickListener listener) |
void |
setOnMarkerDragListener(Marker.OnMarkerDragListener listener) |
void |
setPanToView(boolean panToView)
If set to true, when clicking the marker, the map will be centered on the marker position.
|
void |
setPosition(GeoPoint position)
sets the location on the planet where the icon is rendered
|
void |
setRotation(float rotation)
rotates the icon in relation to the map
|
void |
setTextIcon(String pText) |
void |
setTextLabelBackgroundColor(int mTextLabelBackgroundColor)
used for when the icon is explicitly set to null and the title is not, this will
style the rendered text label
|
void |
setTextLabelFontSize(int mTextLabelFontSize)
used for when the icon is explicitly set to null and the title is not, this will
style the rendered text label
|
void |
setTextLabelForegroundColor(int mTextLabelForegroundColor)
used for when the icon is explicitly set to null and the title is not, this will
style the rendered text label
|
void |
setVisible(boolean visible) |
void |
showInfoWindow()
shows the info window, if it's open, this will close and reopen it
|
closeInfoWindow, getId, getInfoWindow, getRelatedObject, getSnippet, getSubDescription, getTitle, isInfoWindowOpen, onDestroy, setId, setInfoWindow, setRelatedObject, setSnippet, setSubDescription, setTitle
draw, drawAt, getBounds, getSafeMenuId, getSafeMenuIdSequence, isEnabled, onDoubleTap, onDoubleTapEvent, onDown, onFling, onKeyDown, onKeyUp, onPause, onResume, onScroll, onShowPress, onSingleTapUp, onTrackballEvent, setEnabled
protected int mTextLabelBackgroundColor
protected int mTextLabelForegroundColor
protected int mTextLabelFontSize
protected Drawable mIcon
protected GeoPoint mPosition
protected float mBearing
protected float mAnchorU
protected float mAnchorV
protected float mIWAnchorU
protected float mIWAnchorV
protected float mAlpha
protected boolean mDraggable
protected boolean mIsDragged
protected boolean mFlat
protected Marker.OnMarkerClickListener mOnMarkerClickListener
protected Marker.OnMarkerDragListener mOnMarkerDragListener
protected Drawable mImage
protected boolean mPanToView
protected float mDragOffsetY
protected Point mPositionPixels
protected Resources mResources
public static final float ANCHOR_CENTER
public static final float ANCHOR_LEFT
public static final float ANCHOR_TOP
public static final float ANCHOR_RIGHT
public static final float ANCHOR_BOTTOM
public Marker(MapView mapView)
public void setIcon(Drawable icon)
setAnchor(float, float)
Two exceptions:
- for text icons, the anchor is set to (center, center)
- for the default icon, the anchor is set to the corresponding position (the tip of the teardrop)
Related methods: setTextIcon(String)
, setDefaultIcon()
and setAnchor(float, float)
icon
- if null, the default osmdroid marker is used.public void setDefaultIcon()
public void setTextIcon(String pText)
public Drawable getIcon()
public GeoPoint getPosition()
public void setPosition(GeoPoint position)
position
- public float getRotation()
public void setRotation(float rotation)
rotation
- public void setAnchor(float anchorU, float anchorV)
anchorU
- WIDTH 0.0-1.0 precentage of the icon that offsets the logical center from the actual pixel center pointanchorV
- HEIGHT 0.0-1.0 precentage of the icon that offsets the logical center from the actual pixel center pointpublic void setInfoWindowAnchor(float anchorU, float anchorV)
public void setAlpha(float alpha)
public float getAlpha()
public void setDraggable(boolean draggable)
public boolean isDraggable()
public void setFlat(boolean flat)
public boolean isFlat()
public void remove(MapView mapView)
mapView
- public void setOnMarkerClickListener(Marker.OnMarkerClickListener listener)
public void setOnMarkerDragListener(Marker.OnMarkerDragListener listener)
public void setImage(Drawable image)
public Drawable getImage()
public void setDragOffset(float mmUp)
public float getDragOffset()
public void setInfoWindow(MarkerInfoWindow infoWindow)
public void setPanToView(boolean panToView)
public void showInfoWindow()
public boolean isInfoWindowShown()
public void draw(Canvas canvas, Projection pj)
public void onDetach(MapView mapView)
@Deprecated public static void cleanDefaults()
public boolean hitTest(MotionEvent event, MapView mapView)
public boolean onSingleTapConfirmed(MotionEvent event, MapView mapView)
Overlay
return false
). If you handled the Event, return true
, otherwise return false
. If you returned true
none of the following Overlays
or the underlying MapView
has the chance to handle this event.onSingleTapConfirmed
in class Overlay
public void moveToEventPosition(MotionEvent event, MapView mapView)
public boolean onLongPress(MotionEvent event, MapView mapView)
Overlay
return false
). If you handled the Event, return true
, otherwise return false
. If you returned true
none of the following Overlays
or the underlying MapView
has the chance to handle this event.onLongPress
in class Overlay
public boolean onTouchEvent(MotionEvent event, MapView mapView)
Overlay
return false
). If you handled the Event, return true
, otherwise return false
. If you returned true
none of the following Overlays
or the underlying MapView
has the chance to handle this event.onTouchEvent
in class Overlay
public void setVisible(boolean visible)
protected boolean onMarkerClickDefault(Marker marker, MapView mapView)
public int getTextLabelBackgroundColor()
public void setTextLabelBackgroundColor(int mTextLabelBackgroundColor)
public int getTextLabelForegroundColor()
public void setTextLabelForegroundColor(int mTextLabelForegroundColor)
public int getTextLabelFontSize()
public void setTextLabelFontSize(int mTextLabelFontSize)
public boolean isDisplayed()
protected void drawAt(Canvas pCanvas, int pX, int pY, float pOrientation)