Beispiel #1
0
  /**
   * @param context the enclosing MapActivity instance.
   * @param attributeSet a set of attributes.
   * @throws IllegalArgumentException if the context object is not an instance of {@link
   *     MapActivity} .
   */
  public MapView(Context context, AttributeSet attributeSet) {
    super(context, attributeSet);

    if (!(context instanceof MapActivity)) {
      throw new IllegalArgumentException("context is not an instance of MapActivity");
    }

    this.setWillNotDraw(true);

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    dpi = Math.max(metrics.xdpi, metrics.ydpi);

    // TODO make this dpi dependent
    Tile.SIZE = 400;

    MapActivity mapActivity = (MapActivity) context;

    mMapViewPosition = new MapViewPosition(this);
    mMapPosition = new MapPosition();

    mLayerManager = new LayerManager(context);

    mGLView = new GLView(context, this);

    mDebugSettings = new DebugSettings();

    // FIXME
    MapTileLoader.setDebugSettings(mDebugSettings);

    mapActivity.registerMapView(this);

    LayoutParams params =
        new LayoutParams(
            android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.MATCH_PARENT);

    addView(mGLView, params);

    mLayerManager.add(0, new MapEventLayer(this));

    clearMap();
    redrawMap(false);
  }
Beispiel #2
0
  /**
   * Sets the center of the MapView and triggers a redraw.
   *
   * @param geoPoint the new center point of the map.
   */
  public void setCenter(GeoPoint geoPoint) {

    mMapViewPosition.setMapCenter(geoPoint);
    redrawMap(true);
  }
Beispiel #3
0
 /** Request to render a frame. Use this for animations. */
 public void render() {
   if (mClearMap) redrawMap(false);
   else mGLView.requestRender();
 }