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

后端 未结 2 1526
予麋鹿
予麋鹿 2021-01-24 16:47

I would like to make markers that doesn\'t move when the map rotates, exactly like the polylines. My goal is to give the marker a single orientation that never changes even when

2条回答
  •  借酒劲吻你
    2021-01-24 17:21

    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.

提交回复
热议问题