iPhone 地图视图上的热图......?

发布于 2025-01-02 18:51:45 字数 178 浏览 0 评论 0原文

我的客户想要显示他收到更新的所有国家/地区的热图。就像如果他的一家商店在美国关门了,他希望我用红色显示整个国家,如果在巴西开了一家新店,那么它应该用绿色显示巴西。当我点击巴西时,它会放大并显示商店开门和关门地点的图钉注释。

所以我的问题是有人可以指导我如何在地图视图上以特定颜色显示特定国家/地区。

提前致谢。

My client wants to show a heat map of all the countries from where ever he recieves updates. Like if one of his shop closed in America he wants me to show entire country in red color and if a new one opened in Brazil then it should show brazil in green color. And when I tap on brazil it zooms in and shows pin annotations for where ever the shops are opened and closed.

So my question is can someone guide me how to show a particular country on map view in a particular color..

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不奢求什么 2025-01-09 18:51:45

好吧,我已经找到了解决方案。我就是这样做的。

  1. 您需要获取我从 http://thematicmapping.org/downloads/world_borders.php 。您可以从这里获取数据集并使用 QGIS 软件将 .shp 文件转换为 .kml 格式 http://hub.qgis.org/projects/quantum-gis/wiki/Download

  2. 现在从 KML 中提取边界坐标,然后用它在地图上绘制 MKPolygon。

这就是它的样子..

在此处输入图像描述

希望这对某人有帮助。

Well I have found a solution to this.. and this is how I did it..

  1. You need to get the co-ordinates of the boundaries of the countries which I got from http://thematicmapping.org/downloads/world_borders.php . you can get the data set and convert the .shp file into .kml format using QGIS software from here http://hub.qgis.org/projects/quantum-gis/wiki/Download.

  2. Now extract the boundary co-ordinates from KML and then use it to draw MKPolygon on the map.

and this is how it will look like ..

enter image description here

hoping this helps somebody.

若沐 2025-01-09 18:51:45

我预计你会被否决,因为 StackOverflow 社区喜欢那些尝试解决问题的人,做一些研究并思考他们的问题,然后提出一个可以在几段中回答的问题。

问“有人让我这样做,我没有考虑如何尝试,而是来到这里”之类的问题,会让你被否决。

您可以在 MapKit 中完成此操作,通过跟踪所有国家/地区并使用 MKPolygons 重新创建其多边形,但是获取该多边形数据将是一个困难的手动过程。

更简单的方法可能是从库存艺术网站中找到世界矢量地图,然后在 Photoshop 中剪出每个国家/地区并将其导出为具有透明背景的单独绿色位图,这样您就可以为每个国家/地区提供单独的图像和单独的图像。背景图像,所有国家/地区均为红色。

然后在您的应用程序中,将地图图像放入启用缩放的 UIScrollview 中。如果您需要缩放得非常远,则需要使用 CATiledLayer 并进一步分割图像,但出于您的目的,您可能可以使用大约 2 - 3 倍 iPhone 屏幕大小的大图像。

当一个国家/地区有一家新商店时,您需要将该商店的位置与地图上的国家/地区图像位置进行比较(可能最简单的方法是仅保留商店与国家/地区的内部字典,而不是尝试根据其位置来计算)飞行中的 GPS 位置)并在地图的滚动视图内绘制适当的绿色图像。

然后,当您放大时,将商店绘制为地图上正确位置的小图像。同样,您需要手动检查并计算出所有这些位置并将其存储在 Plist 或其他内容中。

显然,这样做的每一步本身都可能是一个 StackOverflow 问题,但尝试一下,看看你在哪里陷入困境,然后回来提出更多问题。

I expect that you were downvoted because the StackOverflow community likes people who have a go at solving their problem, do a bit or research and thinking about their problem and then ask a question that can be answered in a couple of paragraphs.

Asking a question like "somebody asked me to do this, and instead of thinking about how I might attempt it, I just came here" gets you downvoted.

You can do this in MapKit, by tracing all the countries and recreating their polygons using MKPolygons, but it's going to be a difficult manual process to get that polygon data.

What may be easier is to find a vector map of the world from a stock art site, then in Photoshop, cut out each country and export it as separate green bitmaps with transparent backgrounds, so you have a separate image for each country and a separate background image with all the countries in red.

Then in your app, you put your map image in a UIScrollview with zooming enabled. If you need to zoom really far the you'll need to use a CATiledLayer and chop up the images even more, but for your purposes you can probably get away with a big image that's about 2 - 3 x the size of the iPhone screen.

When a country has a new shop in it, you'll need to compare the position of that shop against the country image position on the map (probable easiest to just keep an internal dictionary of shops against country rather than trying to calculate this from their GPS position on the fly) and draw the appropriate green image inside the scrollview in from of the map.

Then when you zoom in, draw your shops as small images at the correct positions on the map. Again, you'll need to go through manually and work out what all those positions will be and store it in a Plist or something.

Obviously each step of doing this could be a StackOverflow question in its own right, but try it and see where you get stuck, and then come back and ask more questions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文