How to create a legend window?

Topics: SharpMap v0.9 / v1.x, SharpMap v2.0, Web Controls
Aug 17, 2007 at 4:54 AM
How can I draw a Legend window when I create a thermatic map? Anyone can help me? Thanks.

Coordinator
Aug 21, 2007 at 12:58 AM
Hi lwj1976 -

There is nothing built into SharpMap which does this automatically: you'd have to look at the Style object that the theme generates and draw a legend from that data. Something like this would make a great contrib to SharpMap! (hint, hint)
Aug 21, 2007 at 6:25 AM
hi,
I have added two classes forlegend and add some code in map.cs for adding legend. and added one function in custometheme and grdient theme class. I can post the complete solution with a example on site. Codekaizen can you guide me where I can place that code.
Aug 21, 2007 at 6:53 AM
Hi Sumeet

It sounds very exciting that you have completed the Legend window. Can you give me a help with the example? My email: Leewj@sh163.net. Thanks.
Aug 21, 2007 at 7:18 AM
hi lwj1976!
I have posted the complete solution to the workitem. you can obtain it from there.

http://www.codeplex.com/SharpMap/WorkItem/View.aspx?WorkItemId=12341

for drawing legend you have to set the property haslegend=true in ajaxfrm.aspx.cs.
Aug 22, 2007 at 5:13 AM
Thats a good contribution. May be a little more refinement could put you in the contributers list. Thanks anyways.
Aug 23, 2007 at 5:16 AM
Edited Aug 23, 2007 at 5:17 AM

Sumeet wrote:
hi lwj1976!
I have posted the complete solution to the workitem. you can obtain it from there.

http://www.codeplex.com/SharpMap/WorkItem/View.aspx?WorkItemId=12341

for drawing legend you have to set the property haslegend=true in ajaxfrm.aspx.cs.


Can you tell me whether legend is stored on a single layer ? and how to put this legend on lowerright corner ? any example ?
thanks... :-) badly english, i'm chinese.
Aug 23, 2007 at 5:55 AM

The legend is get calculated and draws a bitmap this bitmap is merged with graphic object of map. this is not get stored on a single layer. the code is there to put the legend in lower right corner. all you have to do is to set ajaxmap.haslegend=true in the aspx.cs file where u kept the ajaxmap control. you can view the example by extracting the zip file from workitem open the solution and run the ajaxmapfrm.aspx. before running the page set ajaxMap.HasLegend = true; in line 65 of ajaxmapfrm.aspx.cs.

thanks .
Aug 23, 2007 at 6:09 AM
Edited Aug 23, 2007 at 6:43 AM
thanks for quickly response. :-)

terrible sorry, i'm so so careless that i pay no attention to the demoWebSite.

i find some problem in this demo.
The color display on the map is not corrispond diaplay on the legend. on the other word, the color count of legend is not equal to the map. In the piecharts the legend's color is not the piechart's color.
and how to add my own text to the legend ?
if i want to generate an image with legend through web service, the principle is same ?

sorry, i bother you so much.
Aug 23, 2007 at 8:23 AM


cdqrain wrote:
thanks for quickly response. :-)

terrible sorry, i'm so so careless that i pay no attention to the demoWebSite.

i find some problem in this demo.
The color display on the map is not corrispond diaplay on the legend. on the other word, the color count of legend is not equal to the map. In the piecharts the legend's color is not the piechart's color.
and how to add my own text to the legend ?
if i want to generate an image with legend through web service, the principle is same ?

sorry, i bother you so much.


I have tested the dll. in gradient map whatever color you supply and whatever the values are of max and min of value of which u want thematic. the legend piks the color from that. i you gave colorblend.rainbow7 then legend gave the color values for that particular range for that thematic fields value.
currently I made the legend specific for 5 series and its for map only I have to enhance it for charts too. your suggestions are welcome to make it general.
and sorry I am not getting your point on generating image with legend through web service.
Aug 23, 2007 at 9:56 AM
there is red color display in gradient map, but the legend dont have red color.

i want to generate thematic map image(add legend to this image) on the method of web service(asmx),
how to implement it ?
thanks...