动态绘制多边形在谷歌地图 [英] Dynamically drawing polygons in Google map

查看:395
本文介绍了动态绘制多边形在谷歌地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的机器人。我一直在试图视场适用于谷歌地图我的当前位置。图像显示在谷歌地图iOS中一个FOV。

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.

所以基本上我在为了使整个FOV一个gradiant加入5三角形具有不同的α做了类似的事情。

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

我要更新根据设备的方位这一FOV,所以我删除这些三角形,重新计算并重新添加。

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)));

    }

视野总是闪烁,gc_concurrent总是发生。是否有可能使它不闪烁?

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

感谢

推荐答案

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

根据上面的谷歌文档。

According to the Google documentation above.

您应通过调用更新形状
Polygon.setPoints <一个href=\"https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/Polygon?hl=zh-TW#setPoints%28java.util.List%3Ccom.google.android.gms.maps.model.LatLng%3E%29\"相对=nofollow>链接

You shall update the shape by calling Polygon.setPoints Link

而不是删除/添加。

希望这将有助于

这篇关于动态绘制多边形在谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆