示例#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);
  }
示例#2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map);

    mMapView = (MapView) findViewById(R.id.mapView);
    registerMapView(mMapView);

    MapRenderer.setBackgroundColor(0xff777777);
    mMap.layers().add(new TileGridLayer(mMap, Color.GRAY, 1.8f, 8));

    if (USE_CACHE) {
      mCache = new TileCache(this, null, mTileSource.getClass().getSimpleName());
      mCache.setCacheSize(512 * (1 << 10));
      mTileSource.setCache(mCache);
    }

    mBitmapLayer = new BitmapTileLayer(mMap, mTileSource);
    mMap.layers().add(mBitmapLayer);

    // loooop(1);
  }
示例#3
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   if (USE_CACHE) mCache.dispose();
 }