Package globus.glmap

Class GLMapDrawable

java.lang.Object

@ParametersAreNonnullByDefault
public class GLMapDrawable
extends GLMapDrawObject
GLMapDrawable is a bridge class that displays single object on map. This can be image, text or vector object.
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static interface  GLMapDrawable.TransformMode  
  • Constructor Summary

    Constructors
    Constructor Description
    GLMapDrawable()
    Creates new empty image that will be injected to map
    GLMapDrawable​(int drawOrder)
    Creates new empty image with given draw order
    GLMapDrawable​(android.graphics.Bitmap bitmap, int drawOrder)
    Creates image with given draw order and sets bitmap to it
  • Method Summary

    Modifier and Type Method Description
    float getAngle()
    Angle of image
    int getHeight()
    Loaded image height.
    MapPoint getOffset()
    Offset of image
    MapPoint getPosition()
    Position of image
    double getScale()
    Scale of vector object
    int getWidth()
    Loaded image width.
    boolean hitTest​(GLMapView mapView, float screenX, float screenY, int paddingLeft, int paddingRight, int paddingTop, int paddingBottom)
    Tests if point is inside of image
    boolean isRotatesWithMap()
    Whether image rotates with the map
    void setAngle​(float angle)
    Sets angle of image.
    void setBitmap​(android.graphics.Bitmap bitmap)
    Sets new image to draw
    void setBitmap​(android.graphics.Bitmap bitmap, java.lang.Runnable onReadyToDraw)
    Sets new image to draw
    void setOffset​(int offsetX, int offsetY)
    Image offset from position.
    void setPosition​(MapPoint position)
    Sets position of image on map.
    void setRotatesWithMap​(boolean rotate)
    Sets whether image rotates with the map.
    void setScale​(double scale)
    Scale of vector object
    void setText​(java.lang.String text, GLMapVectorStyle style)
    Sets new text to draw
    void setText​(java.lang.String text, GLMapVectorStyle style, java.lang.Runnable onReadyToDraw)
    Sets new text to draw
    void setTransformMode​(int transformMode)
    If drawable contains vector object and you will use position and scale to transform vector object, then set this to TransformMode.Custom.
    void setVectorObject​(GLMapVectorObject object, GLMapVectorCascadeStyle style, java.lang.Runnable onReadyToDraw)
    Sets vector object to draw
    void setVectorObjects​(GLMapVectorObjectList objects, GLMapVectorCascadeStyle style, java.lang.Runnable onReadyToDraw)
    Sets vector objects to draw

    Methods inherited from class globus.glmap.GLMapDrawObject

    getDrawOrder, isHidden, setHidden

    Methods inherited from class globus.glmap.GLNativeObject

    dispose

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GLMapDrawable

      public GLMapDrawable​(int drawOrder)
      Creates new empty image with given draw order
      Parameters:
      drawOrder - Draw order used to sort objects on map
    • GLMapDrawable

      public GLMapDrawable​(android.graphics.Bitmap bitmap, int drawOrder)
      Creates image with given draw order and sets bitmap to it
      Parameters:
      bitmap - bitmap to set
      drawOrder - Draw order used to sort objects on map
    • GLMapDrawable

      public GLMapDrawable()
      Creates new empty image that will be injected to map
  • Method Details

    • setBitmap

      public void setBitmap​(android.graphics.Bitmap bitmap, @Nullable java.lang.Runnable onReadyToDraw)
      Sets new image to draw
      Parameters:
      bitmap - new image to draw
      onReadyToDraw - optional runnable that called when image ready to draw
    • setBitmap

      public void setBitmap​(android.graphics.Bitmap bitmap)
      Sets new image to draw
      Parameters:
      bitmap - new image to draw
    • setText

      public void setText​(java.lang.String text, GLMapVectorStyle style, @Nullable java.lang.Runnable onReadyToDraw)
      Sets new text to draw
      Parameters:
      text - new text to draw
      style - style of the text
      onReadyToDraw - optional runnable that called when text ready to draw
    • setText

      public void setText​(java.lang.String text, GLMapVectorStyle style)
      Sets new text to draw
      Parameters:
      text - new text to draw
      style - style of the text
    • setVectorObject

      public void setVectorObject​(GLMapVectorObject object, GLMapVectorCascadeStyle style, @Nullable java.lang.Runnable onReadyToDraw)
      Sets vector object to draw
      Parameters:
      object - object to draw
      style - style of object
      onReadyToDraw - optional runnable that called when object is ready to draw
    • setVectorObjects

      public void setVectorObjects​(GLMapVectorObjectList objects, GLMapVectorCascadeStyle style, @Nullable java.lang.Runnable onReadyToDraw)
      Sets vector objects to draw
      Parameters:
      objects - objects to draw
      style - style of object
      onReadyToDraw - optional runnable that called when object is ready to draw
    • hitTest

      public boolean hitTest​(GLMapView mapView, float screenX, float screenY, int paddingLeft, int paddingRight, int paddingTop, int paddingBottom)
      Tests if point is inside of image
      Parameters:
      mapView - mapView where image is displayed
      screenX - x coordinate of point to check
      screenY - y coordinate of point to check
      paddingLeft - left padding
      paddingRight - right padding
      paddingTop - top padding
      paddingBottom - bottom padding
      Returns:
      `true` if point is inside image
    • setPosition

      public void setPosition​(MapPoint position)
      Sets position of image on map. image.setPosition(GLMapView.convertGeoToInternal(new MapPoint(-74.0, 40.7))); //New York
      Parameters:
      position - position coordinates in internal format of GLMapView
      See Also:
      MapPoint
    • getPosition

      public MapPoint getPosition()
      Position of image
      Returns:
      position of image in internal coordinates of GLMapView
    • setScale

      public void setScale​(double scale)
      Scale of vector object
      Parameters:
      scale - new scale for vector object
    • getScale

      public double getScale()
      Scale of vector object
      Returns:
      scale of vector object
    • setAngle

      public void setAngle​(float angle)
      Sets angle of image. image.setAngle(45);
      Parameters:
      angle - angle to set
    • getAngle

      public float getAngle()
      Angle of image
      Returns:
      angle of image in degrees.
    • getWidth

      public int getWidth()
      Loaded image width.
      Returns:
      width of image in pixels.
    • getHeight

      public int getHeight()
      Loaded image height.
      Returns:
      height of image in pixels.
    • setRotatesWithMap

      public void setRotatesWithMap​(boolean rotate)
      Sets whether image rotates with the map.
      Parameters:
      rotate - true to rotate with map
    • isRotatesWithMap

      public boolean isRotatesWithMap()
      Whether image rotates with the map
      Returns:
      true if image rotates with the map
    • setOffset

      public void setOffset​(int offsetX, int offsetY)
      Image offset from position. When offset is (0,0), bottom left corner of image is displayed at position image.setOffset(bmp.getWidth()/2, bmp.getHeight()/2); // image center displayed at position
      Parameters:
      offsetX - x offset of image
      offsetY - y offset of image
      See Also:
      setPosition(MapPoint)
    • setTransformMode

      public void setTransformMode​(int transformMode)
      If drawable contains vector object and you will use position and scale to transform vector object, then set this to TransformMode.Custom.
      Parameters:
      transformMode - mode of transforming position and scale
    • getOffset

      public MapPoint getOffset()
      Offset of image
      Returns:
      offset of image in pixels