Пример #1
0
  @Override
  public void createLayers() {
    mMap.setMapPosition(53.08, 8.83, 1 << 14);

    // TileSource tileSource = new OSciMap4TileSource();

    MapFileTileSource tileSource = new MapFileTileSource();
    // tileSource.setMapFile("/home/jeff/src/vtm/Freizeitkarte_DEU_NW.map");
    tileSource.setMapFile("/home/jeff/germany.map");

    VectorTileLayer l = mMap.setBaseMap(tileSource);
    mapLayer = l;

    // mMap.getLayers().add(new BuildingLayer(mMap, l.getTileLayer()));
    mMap.layers().add(new LabelLayer(mMap, l));

    try {
      IRenderTheme theme = ThemeLoader.load("themes/freizeitkarte/theme.xml");
      // IRenderTheme theme =
      // ThemeLoader.load("themes/elevate/theme.xml");
      // IRenderTheme theme = ThemeLoader.load("themes/vmap/theme.xml");
      l.setRenderTheme(theme);
      MapRenderer.setBackgroundColor(theme.getMapBackground());
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }

    // mMap.getLayers().add(new GenericLayer(mMap, new MeshRenderer()));
    // mMap.getLayers().add(new GenericLayer(mMap, new GridRenderer()));
  }
Пример #2
0
  @Override
  public void createLayers() {
    MapRenderer.setBackgroundColor(0xf0f0f0);

    TileSource ts = new OSciMap4TileSource();
    VectorTileLayer l = mMap.setBaseMap(ts);

    mMap.setTheme(VtmThemes.DEFAULT);
    RenderTheme t = (RenderTheme) l.getTheme();
    mTheme = t;
    // t.traverseRules(new DesaturateAreaStyles());
    // t.traverseRules(new DesaturateLineStyles());
    t.traverseRules(new SaturateLineStyles(0.5, true, true, true));
    t.updateStyles();

    // mMap.setMapPosition(7.707, 81.689, 1 << 16);

    mMap.setMapPosition(53.08, 8.82, 1 << 16);
  }
Пример #3
0
  @Override
  protected boolean onKeyDown(int keycode) {
    String name = null;
    if (keycode == Input.Keys.NUM_1) name = "themes/freizeitkarte/theme.xml";
    if (keycode == Input.Keys.NUM_2) name = "themes/elevate/theme.xml";
    if (keycode == Input.Keys.NUM_3) name = "themes/vmap/theme.xml";

    if (name == null) return false;

    try {
      IRenderTheme theme = ThemeLoader.load(name);
      mapLayer.setRenderTheme(theme);
      MapRenderer.setBackgroundColor(theme.getMapBackground());
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }

    mMap.clearMap();
    mMap.updateMap(true);
    return true;
  }
Пример #4
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);
  }
Пример #5
0
 public void setTheme(MapzenStyle.Theme theme) {
   IRenderTheme t = ThemeLoader.load(theme);
   baseLayer.setRenderTheme(t);
   MapRenderer.setBackgroundColor(t.getMapBackground());
   getMap().clearMap();
 }
Пример #6
0
 @Override
 public void onDrawFrame(GL10 gl) {
   super.onDrawFrame();
 }
Пример #7
0
 @Override
 public void onSurfaceChanged(GL10 gl, int width, int height) {
   super.onSurfaceChanged(width, height);
 }
Пример #8
0
 @Override
 public void onSurfaceCreated(GL10 gl, EGLConfig config) {
   super.onSurfaceCreated();
 }
Пример #9
0
  public void onSurfaceChanged(int width, int height) {
    // log.debug("onSurfaceChanged: new={}, {}x{}", mNewSurface, width, height);

    if (width <= 0 || height <= 0) return;

    gl.viewport(0, 0, width, height);

    // GL.scissor(0, 0, width, height);
    // GL.enable(GL20.SCISSOR_TEST);

    gl.clearStencil(0x00);

    gl.disable(GL.CULL_FACE);
    gl.blendFunc(GL.ONE, GL.ONE_MINUS_SRC_ALPHA);

    gl.frontFace(GL.CW);
    gl.cullFace(GL.BACK);

    if (!mNewSurface) {
      mMap.updateMap(false);
      return;
    }

    mNewSurface = false;

    /** initialize quad indices used by Texture- and LineTexRenderer */
    int[] vboIds = GLUtils.glGenBuffers(2);

    mQuadIndicesID = vboIds[0];

    short[] indices = new short[MAX_INDICES];
    for (int i = 0, j = 0; i < MAX_INDICES; i += 6, j += 4) {
      indices[i + 0] = (short) (j + 0);
      indices[i + 1] = (short) (j + 1);
      indices[i + 2] = (short) (j + 2);

      indices[i + 3] = (short) (j + 2);
      indices[i + 4] = (short) (j + 1);
      indices[i + 5] = (short) (j + 3);
    }
    ShortBuffer buf = MapRenderer.getShortBuffer(indices.length);
    buf.put(indices);
    buf.flip();

    GLState.bindElementBuffer(mQuadIndicesID);
    gl.bufferData(GL.ELEMENT_ARRAY_BUFFER, indices.length * 2, buf, GL.STATIC_DRAW);
    GLState.bindElementBuffer(0);

    /** initialize default quad */
    FloatBuffer floatBuffer = MapRenderer.getFloatBuffer(8);
    float[] quad = new float[] {-1, -1, -1, 1, 1, -1, 1, 1};
    floatBuffer.put(quad);
    floatBuffer.flip();
    mQuadVerticesID = vboIds[1];

    GLState.bindVertexBuffer(mQuadVerticesID);
    gl.bufferData(GL.ARRAY_BUFFER, quad.length * 4, floatBuffer, GL.STATIC_DRAW);
    GLState.bindVertexBuffer(0);

    GLState.init();

    mMap.updateMap(true);
  }