admin管理员组

文章数量:1245088

I need to write a webpage which starts with a blank map of the US and colors the states according to data it receives from various Ajax requests. The map needs to change over time without the page reloading, and the user can click on various controls to instantly change how the map is colored. This all needs to be done locally, so I can't make use of Google maps or any similar internet service.

I'd hope to do this in the browser with Javascript. Is there a good library for doing this? Or any general suggestions for how to best implement this?

I need to write a webpage which starts with a blank map of the US and colors the states according to data it receives from various Ajax requests. The map needs to change over time without the page reloading, and the user can click on various controls to instantly change how the map is colored. This all needs to be done locally, so I can't make use of Google maps or any similar internet service.

I'd hope to do this in the browser with Javascript. Is there a good library for doing this? Or any general suggestions for how to best implement this?

Share Improve this question asked Apr 24, 2009 at 13:27 Eli CourtwrightEli Courtwright 193k68 gold badges223 silver badges257 bronze badges 2
  • 1 Can you use flash? This sounds like a great job for Flash. – Daniel A. White Commented Apr 24, 2009 at 13:29
  • Unfortunately Flash isn't an option. It's possible that Java Applets might be permissible, but the client won't have Flash installed in many of their browsers, which makes it a non-starter. – Eli Courtwright Commented Apr 24, 2009 at 13:33
Add a ment  | 

4 Answers 4

Reset to default 10

I would take a plugin like this just change it to do "highlighting" based on your dynamic data:

  • http://plugins.jquery./project/maphilight

  • Demo of plugin: http://davidlynch/js/maphilight/docs/demo_usa.html

Currently it highlights on mouseover, but highlighting using data given should be very straightforward.

The fact it es with a map of the US and highlighting ready to go set is just gravy.

Sounds like a job for Raphaël

Here is example of pure JS, SVG/VML solution: http://jvectormap.owl-hollow/

You may still be able to use the Google Static Maps API's "path" parameter to overlay the color you want. Create some static maps and save the resulting image.

http://code.google./apis/maps/documentation/staticmaps/index.html#Paths

本文标签: Dynamically coloring a US map with JavascriptStack Overflow