gpt4 book ai didi

android - 在谷歌地图中动态绘制多边形

转载 作者:太空狗 更新时间:2023-10-29 14:21:22 26 4
gpt4 key购买 nike

我是安卓新手。我一直在尝试将视野应用到我在谷歌地图中的当前位置。该图像显示了 iOS 中 Google map 上的 FOV。

enter image description here

所以基本上我做了类似的事情,添加了 5 个具有不同 alpha 的三角形,以使整个 fov 成为渐变。

enter image description here

我必须根据设备的方位角更新这个 fov,所以我删除了那些三角形,重新计算它们并再次添加它们。

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

}

fov 一直在闪烁,gc_concurrent 一直在发生。有没有可能让它不眨眼?

谢谢

最佳答案

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

根据上面的 Google 文档。

你应该通过调用来更新形状多边形.setPoints Link

而不是删除/添加。

希望对你有帮助

关于android - 在谷歌地图中动态绘制多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16667295/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com