如何在iOS(iPhone / iPad)上实现密度/热图效果? [英] How to achieve density/heat map effect in iOS (iPhone/iPad)?

查看:420
本文介绍了如何在iOS(iPhone / iPad)上实现密度/热图效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://www.econguru .com / heat-map-of-worldwide-gdp-ppp-per-capita-2008 /

这是CIA world Factbook地图,每个国家都有根据国内生产总值的不同颜色深度。高GDP国家有更深的颜色。

This is CIA world Factbook map, each country has different color depth based on their GDP number. High GDP country has deeper color.

现在,我正在考虑将这样的效果发展成我的iPhone / iPad地图应用程序。我可能想使用苹果地图(可能不是谷歌地图,因为iOS 6有自己的地图),但我不知道如何根据用户访问的国家获得这样的效果。

Right now, I am considering to develop such effect into my iPhone/iPad map app. I may want to use the apple map (probably not google map since iOS 6 has its own map), but I am not sure how to get such effect based on the country the user visited.

例如,用户访问了美国,然后地图在美国显示更深的颜色。

For example, the user visited US the most, then the map shows deeper color in US.

I还没有在iPhone应用程序中看到这样的效果。任何建议将不胜感激!

I haven't seen such effect in iPhone app yet. Any suggestion would be appreciated!

推荐答案

这应该是可以使用MapKit和覆盖。您需要为热图的每个区域构建叠加层,然后根据数据设置颜色。我怀疑最难的部分是获取您需要构建每个地区的路径所需的地理数据。 AFAICT,MapKit中没有 -pathForState: -pathForCountry:函数类型,因此您将需要找到该信息的另一个来源。但是,在绘制叠加层面,MapKit全部在这里。请查看此示例代码

This should be doable using MapKit and overlays. You would need to construct an overlay for each area of the heat map and then set the color according to the data. I suspect the hardest part is going to be getting the geographic data you need to construct the paths for each region. AFAICT, there's no -pathForState: or -pathForCountry: type of functions in MapKit, so you're going to need to find another source for that information. But in terms of drawing overlays, it's all there in MapKit. Check out this sample code.

编辑:

这个问题有一些指向哪里获取该数据的指针。

This question has some pointers on where to get that data.

这篇关于如何在iOS(iPhone / iPad)上实现密度/热图效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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