Heatmap - Generating Simple 'HeatPoint' Google Maps Android

梦想的初衷 提交于 2020-02-28 09:55:14

问题


Android SDK 2.3.3 Google Maps V2

Currently I'm drawing circles overlays and adding them to a MapView. The size is dictated by a certain value and I'm looking to determine the RadialGradient color of the circle by something else.

            circle.setShader(new RadialGradient(pt.x, pt.y, 40, Color.argb(150, 252, 5, 5), Color.argb(60, 234, 231, 0), TileMode.MIRROR));
            canvas.drawCircle(pt.x, pt.y, radius, circle);

It works, however I'd prefer the edges to look more similar to the classic heatpoint map.

Current

What I'd like to achieve (I'd still like the shape to be circular)

I'm thinking of possibly drawing a circle directly underneath the current with a sightly bigger area in order to achieve a more typical heatmap look, however this has performance implications considering I'm doing this on a mobile device which has to re-render per zoom in or out action.


回答1:


There are a few obvious options here, and I'm sure there are many more non-obvious ways to do this as well:

  • Draw multiple concentric circles as you suggested
  • Load a concentric circle pattern from an image and draw that (less rendering, but, of course, you have to load the image)
  • Use a BitmapShader to draw a single circle with a custom gradient that matches what you're looking for: http://developer.android.com/reference/android/graphics/BitmapShader.html

Unfortunately, I don't know which of these options will give you the best performance, so you'll probably have to test them yourself. I suspect that, for a large number of heatmap points, one of the later two options will be more efficient, but that's nothing more than a guess.



来源:https://stackoverflow.com/questions/11762936/heatmap-generating-simple-heatpoint-google-maps-android

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