Dynamically drawing polygons in Google map

和自甴很熟 提交于 2020-01-04 02:05:27

问题


I am new to android. I've been trying to apply a field of view to my current location in google map. The image shows a FOV on Google map in iOS.

So basically I did a similar thing by adding 5 triangles with different alpha in order to make the whole fov a gradiant.

I have to update this fov according to azimuth of the device, so I remove those triangles ,recompute them and add them again.

    for(int i=0; i<5;i++){
        if(triangles[i]!=null){
            triangles[i].remove();
        }
    //triangles=null;

        la = mvalues[0]-hang/2;
        lx = lon+i*Math.sin(Math.toRadians(la))/2775;
        ly = lat+i*Math.cos(Math.toRadians(la))/2775;
        ra = mvalues[0]+hang/2;
        rx = lon+i*Math.sin(Math.toRadians(ra))/2775;
        ry = lat+i*Math.cos(Math.toRadians(ra))/2775;

        triangles[i] = map.addPolygon(new PolygonOptions().add(new LatLng(lat,lon), new LatLng(ly,lx), new LatLng(ry,rx)).strokeColor(Color.TRANSPARENT).fillColor(Color.argb(50, 0, 0, 50)));

    }

The fov is always blinking, and gc_concurrent always happens. Is it possible to make it not blinking?

Thanks


回答1:


https://developers.google.com/maps/documentation/android/shapes

According to the Google documentation above.

You shall update the shape by calling Polygon.setPoints Link

rather than remove/add.

Hope this would help



来源:https://stackoverflow.com/questions/16667295/dynamically-drawing-polygons-in-google-map

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