简体   繁体   English

如何使用Android API V2在GoogleMap上绘制数千个正方形

[英]How to draw thousands squares on GoogleMap using android api V2

I need to draw on a Map ( Google Map android api v2 ) a lot of squares( 1000 + ), and a few circle. 我需要在地图(Google Map android api v2)上绘制很多正方形(1000 +)和几个圆圈。

Under android api V1 it was possible to do that but with the new api it's hard to draw more of 400 squares ( after it's too slow ). 在android api V1下,可以执行此操作,但是使用新api很难绘制更多400平方(过慢)。

So I don't know how to to for solve this problem. 所以我不知道如何解决这个问题。 It is possible to use one google map and a textureView ? 可以使用一个Google Map和TextureView吗? ( for draw my squares in opengl ) (用于在opengl中绘制正方形)

I've got a test file with 1000 polygons and 35000 lat/lng pairs total and am able to load that from a file to a Google Maps V2 map in about 4 seconds on a Nexus 10. I also have a test file of 12000 polygons, 48000 lat/lng pairs, that loads in about 20 seconds. 我有一个包含1000个多边形和总共35000个纬度/经度对的测试文件,并且能够在Nexus 10上大约4秒钟内将其从文件加载到Google Maps V2地图中。我还有一个12000个多边形的测试文件,每对48000纬度/经度,将在20秒内加载完毕。 But supporting datasets larger than that seems to be without a purpose as with this many objects the map is fairly slow to scroll around. 但是支持大于该值的数据集似乎是没有目的的,因为有这么多的对象,地图滚动的速度相当慢。 And the Nexus 10 is one of the fastest Android devices out there. Nexus 10是目前最快的Android设备之一。

I give you these numbers to give you an idea of what performance you might be able to extract. 我给您这些数字,让您大致了解您可以提取的性能。 I would say Maps V2 in general is faster than I was able to do on Maps V1, although my skills are further developed, I have spent more time optimizing, and devices have gotten faster since I was using Maps V1. 我想说Maps V2总体上比我在Maps V1上的速度要快,尽管我的技能得到了进一步的发展,我花了更多的时间进行优化,并且自从我使用Maps V1以来设备变得更快。

Most of the optimizations that I have made actually involved things other than the map itself so you might not want to jump to the assumption that Maps is the problem. 我所做的大多数优化实际上都涉及到地图本身以外的东西,因此您可能不想跳到认为地图是问题的假设。 For instance, I used to load the data from SQLite and didn't have proper indexes on the tables. 例如,我曾经从SQLite加载数据,并且在表上没有正确的索引。 Fixing that gave ~50% speedup. 修复后,速度提高了约50%。 Then I changed my app to load directly from shape files instead of the database and that helped some (but mostly I avoid the slow process of importing to the database). 然后,我将应用程序更改为直接从形状文件而不是从数据库加载,这有所帮助(但大多数情况下,我避免了导入数据库的缓慢过程)。

So in the end my advice to you is to bust out System.getCurrentMillis() (writing to LogCat) and see where the actual performance bottlenecks are. 因此,最后,我的建议是关闭System.getCurrentMillis() (写入LogCat),并查看实际的性能瓶颈在哪里。 1000 squares should have OK performance on Maps V2 although it is probably slow enough to warrant a loading progress indicator. 尽管Maps V2的速度可能足够慢以保证加载进度指示器,但1000平方应该在OK上表现良好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM