Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fill color in an outline state map?

Status
Not open for further replies.

lichtjiang

Programmer
Feb 26, 2007
39
US
I want to write a javascript to display a outline state map such that different states are filled with different color in a web browser such as IE and FireFox.

What I am thinking is as this:

1st, display blank outline state map as a map (.gif?). Blank outline state map is one that has contour for each state with no color filled.
2nd, for all states, make a list of coordinates of its center point.
3rd, call javascript to fill each state from center point with given coords.

So, this is to create colored state map from client browser instead of from server side.

Is this doable and could someone give me some hints? Or is there some existing codes for doing this in a similar or better way?

Thanks a lot!
 
Call me crazy, but if you are going to do step 1 above:

1st, display blank outline state map as a map (.gif?). Blank outline state map is one that has contour for each state with no color filled.

Why not color the .gifs in a graphics editor before they are put on the webpage?


[monkey][snake] <.
 
Because each state may be in different color from one time to another. In other words, color is used as indicator of some property, for example, temperature. And I do not want to create this map on server side in order to avoid managing temp files.
 
Thanks, Feherke. Could you please tutor me some hints about how to do in my case (fill color in a map in .gif or other formats) by using GD library?
 
Hi, Feherke, you mentioned no need to keep temp files. But after a new map filled with colors is created from a blank map on the server side, how to send it with a web page back to client browsers? I think I can put such a map or some picture object as a file somewhere on the server (even temporarily) so that client browser can make request to fetch it and display it later. Though I believe binary data might be responsed with other objects to client browser, I don't know how to do this. Any idea? Thanks.
 
Hi

In basic steps it will be :
[ul]
[li]load the outlined map[/li]
[li]optionally load the predefined fill starting point coordinates[/li]
[li]optionally create a color[/li]
[li]fill the image starting form the given point with the given color[/li]
[li]output the resulted image[/li]
[/ul]
So there will be no temporary file, because the GD library ( and Imager in Perl too ) edits the image in the memory. So the CGI just has to output it like a text.

But this in offtopic. I saw you reposted this in the forum452 ( CGI ) and I will answer there, but not before weekend.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top