I have a country map in .png format, I need to highlight specific states in this map dynamica开发者_如何学JAVAlly using PHP. What's the best way to do this?
Thanks
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.
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
精彩评论