增加Android版Maps API的热图半径 [英] Increase radius on heat map for Maps API on Android

查看:123
本文介绍了增加Android版Maps API的热图半径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Android的Google Maps API上创建了热点地图.问题是当我增加缩放比例时,热图会变松"半径,并且外观不是那么好.

I've created an heat map on Google Maps API for Android. The problem is when I increase zoom, the heat map "looses" radius and the look is not that good.

有一种方法可以将半径增加到50以上(可能是最大值)? :/

There`s a way to increase radius above 50 (Probably the maximum)? :/

推荐答案

来自

半径:应用于热图的高斯模糊的大小, 以像素表示.默认值为20.必须介于10到50之间. 创建热图时使用Builder的radius()设置值,或者 稍后使用setRadius()更改值.

Radius: The size of the Gaussian blur applied to the heatmap, expressed in pixels. The default is 20. Must be between 10 and 50. Use the Builder's radius() to set the value when creating the heatmap, or change the value later with setRadius().

因此,如果您使用HeatmapTileProvider.Builder中的radius(int val)函数,并且半径不在10到50之间,则会收到IllegalArgumentException("Radius not within bounds.")异常.

So, if you use the radius(int val) function from the HeatmapTileProvider.Builder you will receive an IllegalArgumentException("Radius not within bounds.") exception if the radius is not between 10 an 50.

看看 GitHub存储库,您可以看到radius(int val)函数检查参数是否在MIN_RADIUSMAX_RADIUS之间.

Taking a look at the GitHub repository you can see that the radius(int val) function checks if the parameter is between MIN_RADIUS and MAX_RADIUS.

无论如何,您都可以使用HeatmapTileProvider类上的setRadius(int radius)函数(看看

Anyway there is a setRadius(int radius) function on the HeatmapTileProvider class that you can use (take a look at he implementation in the GitHub repository).

因此,由于setRadius(int radius)函数不会检查该参数,因此可以按如下所示调用build()后更改HeatmapTileProvider的半径:

So, as the setRadius(int radius) function does not check the parameter, you can change the radius of the HeatmapTileProvider after calling build() as follows:

HeatmapTileProvider mProvider = new HeatmapTileProvider.Builder()
        .data(list)
        .build();
mProvider.setRadius(100);

以警察局为例,并将半径设置为50:

Using the police stations example, and setting the radius to 50:

并将半径设置为100:

And setting the radius to 100:

您可能要根据缩放级别动态更改HeatMap的半径.

You may want to dynamically change the radius of the HeatMap based on the zoom level.

注意:,请考虑Javac中关于setRadius函数的说明:

NOTE: Take into account that, as stated in the Javadoc for the setRadius function:

用户应在之后清除覆盖的图块缓存(使用clearTileCache()) 叫这个.

User should clear overlay's tile cache (using clearTileCache()) after calling this.

这篇关于增加Android版Maps API的热图半径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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