如何用php突出显示地图中的区域?
我有一个 .png 格式的国家地图,我需要使用 PHP 动态突出显示该地图中的特定州。最好的方法是什么?
谢谢
I have a country map in .png format, I need to highlight specific states in this map dynamically using PHP. What's the best way to do this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要创建定义包围每个状态的多边形的所有点的列表,然后使用 imagepolygon 用某种颜色填充地图图像上适当的多边形。
实际上,您可能想要找到第 3 方库/组件(即 Flash 电影、JavaScript 地图和库,或为此设计的 PHP 类),而不是从头开始自己编写。突出显示地图并不是一个新问题,从头开始再次解决它是乏味的。
You would need to create a list of all the points defining the polygon encasing each state, then use imagepolygon to fill in the appropriate polygons on the map image with some color.
Realistically you probably want to find a 3rd party library/component (i.e. Flash movie, JavaScript map and library, or PHP class designed for this) rather than writing it on your own from scratch. Highlighting a map isn't exactly a new problem and solving it again from scratch is tedious.
如果您谈论的是美国各州,我建议您尝试使用 Google 地图和以下链接。我最近将它们用于您正在谈论的确切目的(按州投票),并且效果很好:
http://econym.org.uk/gmap/example_states2.htm
http://econym.org.uk/gmap/epoly.htm
http://econym.org.uk/gmap/states.xml
If you're talking about US States, I would recommend trying Google Maps, and the following links. I used them for the exact purpose you're talking about (votes by state) recently, and it worked great:
http://econym.org.uk/gmap/example_states2.htm
http://econym.org.uk/gmap/epoly.htm
http://econym.org.uk/gmap/states.xml