Package org.oscim.map

Class Map

java.lang.Object
org.oscim.map.Map
All Implemented Interfaces:
TaskQueue

public abstract class Map extends Object implements TaskQueue
  • Field Details

    • POSITION_EVENT

      public static final Event POSITION_EVENT
      UpdateListener event. Map position has changed.
    • MOVE_EVENT

      public static final Event MOVE_EVENT
      UpdateListener event. Map was moved by user.
    • SCALE_EVENT

      public static final Event SCALE_EVENT
      UpdateListener event. Map was scaled by user.
    • ROTATE_EVENT

      public static final Event ROTATE_EVENT
      UpdateListener event. Map was rotated by user.
    • TILT_EVENT

      public static final Event TILT_EVENT
      UpdateListener event. Map was tilted by user.
    • UPDATE_EVENT

      public static final Event UPDATE_EVENT
      UpdateLister event. Delivered on main-thread when updateMap() was called and no CLEAR_EVENT or POSITION_EVENT was triggered.
    • CLEAR_EVENT

      public static final Event CLEAR_EVENT
      UpdateListerner event. Map state has changed in a way that all layers should clear their state e.g. the theme or the TilesSource has changed. TODO should have an event-source to only clear affected layers.
    • ANIM_END

      public static final Event ANIM_END
    • ANIM_START

      public static final Event ANIM_START
    • input

    • events

    • mAnimator

      protected final Animator mAnimator
    • mMapPosition

      protected final MapPosition mMapPosition
    • mEventLayer

      protected final AbstractMapEventLayer mEventLayer
    • mClearMap

      protected boolean mClearMap
  • Constructor Details

    • Map

      public Map()
  • Method Details

    • getEventLayer

      public AbstractMapEventLayer getEventLayer()
    • setBaseMap

      public VectorTileLayer setBaseMap(TileSource tileSource)
      Create OsmTileLayer with given TileSource and set as base map (layer 1).
    • setBaseMap

      public TileLayer setBaseMap(TileLayer tileLayer)
    • setTheme

      public IRenderTheme setTheme(ThemeFile theme)
      Utility function to set theme of base vector-layer and use map background color from theme.
    • setTheme

      public IRenderTheme setTheme(ThemeFile theme, boolean allLayers)
      Utility function to set theme of base vector-layer, optionally to all vector layers and use map background color from theme.
    • setTheme

      public void setTheme(IRenderTheme theme)
    • setTheme

      public void setTheme(IRenderTheme theme, boolean allLayers)
    • destroy

      public void destroy()
    • updateMap

      public abstract void updateMap()
      Request call to onUpdate for all layers. This function can be called from any thread. Request will be handled on main thread.
    • updateMap

      public abstract void updateMap(boolean redraw)
      Request call to onUpdate for all layers. This function can be called from any thread. Request will be handled on main thread.
      Parameters:
      redraw - pass true to render next frame afterwards
    • render

      public abstract void render()
      Request to render a frame. Request will be handled on main thread. Use this for animations in RenderLayers.
    • post

      public abstract boolean post(Runnable action)
      Post a runnable to be executed on main-thread
      Specified by:
      post in interface TaskQueue
    • postDelayed

      public abstract boolean postDelayed(Runnable action, long delay)
      Post a runnable to be executed on main-thread. Execution is delayed for at least 'delay' milliseconds.
    • addTask

      public void addTask(Runnable task)
      Post a task to run on a shared worker-thread. Should only use for tasks running less than a second.
      Specified by:
      addTask in interface TaskQueue
    • getWidth

      public abstract int getWidth()
      Return view width in pixel.
    • getHeight

      public abstract int getHeight()
      Return view height in pixel.
    • getScreenWidth

      public abstract int getScreenWidth()
      Return screen width in pixel.
    • getScreenHeight

      public abstract int getScreenHeight()
      Return screen height in pixel.
    • clearMap

      public void clearMap()
      Request to clear all layers before rendering next frame
    • setMapPosition

      public void setMapPosition(MapPosition mapPosition)
      Set MapPosition of Viewport and trigger a redraw.
    • setMapPosition

      public void setMapPosition(double latitude, double longitude, double scale)
    • getMapPosition

      public boolean getMapPosition(boolean animationEnd, MapPosition mapPosition)
      Get current MapPosition or at possible animation end.
      Parameters:
      animationEnd - map position at animation end (valid with Animator.animateTo methods)
      mapPosition - reuse MapPosition instance
      Returns:
      true when MapPosition was updated (has changed)
    • getMapPosition

      public boolean getMapPosition(MapPosition mapPosition)
      Get current MapPosition.
      Returns:
      true when MapPosition was updated (has changed)
    • getMapPosition

      public MapPosition getMapPosition()
      Get current MapPosition. Consider using getViewport.getMapPosition(pos) instead to reuse MapPosition instance.
    • getBoundingBox

      public BoundingBox getBoundingBox(int expand)
    • viewport

      public ViewController viewport()
      Returns:
      Viewport instance
    • layers

      public Layers layers()
      Returns:
      Layers instance
    • animator

      public Animator animator()
      Returns:
      MapAnimator instance
    • prepareFrame

      protected void prepareFrame()
      This function is run on main-thread before rendering a frame.

      For internal use only. Do not call!

    • handleGesture

      public boolean handleGesture(Gesture g, MotionEvent e)
    • beginFrame

      public abstract void beginFrame()
      Called on render thread, use synchronized!
    • doneFrame

      public abstract void doneFrame(boolean needsRedraw)
      Called on render thread, use synchronized!