How to add a static map marker in the HERE maps Android sdk?

会有一股神秘感。 提交于 2019-12-02 03:53:22

You can draw a simple rectangle with both front and back facing sides textured as follows:

    // Two triangles
    FloatBuffer buff = FloatBuffer.allocate(12);
    buff.put(0- delta);
    buff.put(0- delta);
    buff.put(1.f);

    buff.put(0 + delta);
    buff.put(0 - delta);
    buff.put(1.f);

    buff.put(0 - delta);
    buff.put(0 + delta);
    buff.put(1.f);

    buff.put(0 + delta);
    buff.put(0 + delta);
    buff.put(1.f);

    // Two triangles to generate the rectangle. Both front and back face
    IntBuffer vertIndicieBuffer = IntBuffer.allocate(12);
    vertIndicieBuffer.put(0);
    vertIndicieBuffer.put(2);
    vertIndicieBuffer.put(1);
    vertIndicieBuffer.put(2);
    vertIndicieBuffer.put(3);
    vertIndicieBuffer.put(1);
    vertIndicieBuffer.put(0);
    vertIndicieBuffer.put(1);
    vertIndicieBuffer.put(2);
    vertIndicieBuffer.put(1);
    vertIndicieBuffer.put(3);
    vertIndicieBuffer.put(2);

    // Texture coordinates
    FloatBuffer textCoordBuffer = FloatBuffer.allocate(8);
    textCoordBuffer.put(0.f);
    textCoordBuffer.put(0.f);
    textCoordBuffer.put(1.f);
    textCoordBuffer.put(0.f);
    textCoordBuffer.put(0.f);
    textCoordBuffer.put(1.f);
    textCoordBuffer.put(1.f);
    textCoordBuffer.put(1.f);

    // The LocalMesh itself.
    LocalMesh mesh = new LocalMesh();
    mesh.setVertices(buff);
    mesh.setVertexIndices(vertIndicieBuffer);
    mesh.setTextureCoordinates(textCoordBuffer);

    MapLocalModel model = new MapLocalModel();
    model.setMesh(mesh);
    model.setDynamicScalingEnabled(true);
    model.setAnchor(new GeoCoordinate(LATITUDE, LONGITUDE, 0.0));

Attach an image to it for texture, and use MapRenderLisener#onPredraw() to change the pitch and yaw of the local model object to follow the camera.

The MapMarker object is what you are looking for? It is anchored to the position you give it and it will always be drawn in screen 2d space regardless of the tilt and rotate you apply to the map.

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!