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

安稳与你 提交于 2019-12-04 05:10:57

问题


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 getsures occure.

I have tried with every marker type but I can't get the wanted effect.

Any kind of help would be appreciated since I am stuck here for really long hours


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/36667245/how-to-add-a-static-map-marker-in-the-here-maps-android-sdk

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