Create legend using Mapbasic

42 views
Skip to first unread message

Peter Horne

unread,
Nov 12, 2024, 2:18:43 AM11/12/24
to MapInfo-L
Hi,
trying to create legend for the following code. The user enters a date range and the code creates a map layer with associated thematic layer. What I want to do is also create the legend associated with the thematic layer. Tried to add a few things eg "Add Designer Frame", but inevitably encounter the error "invalid Window ID". I have researched that error but can't work out the correct code or where to place that code into my code.

My code - 

Include "mapbasic.def"
dim data1 as datetime
dim data2 as datetime

Note "Enter dates for mapping. Map layer will be added to Map"

Dialog
Title "Date format 27/1/1962"
Control StaticText
Title "Begin Date"
Control EditText
Value data1
Into data1
Control StaticText
Title "End Date"
Control EditText
Value data2
Into data2
Control StaticText
Control OKButton
Control CancelButton
If CommandInfo(CMD_INFO_DLG_OK) Then
End If

'****Larval_ALBO_DETECT*********'

Select * from vph_MOSI_BreedingSitesAll Where DATE between formatdate$(Data1) and formatdate$(data2) and SPECIES = Any("Ae albopictus","Ae aegypti","Cx quincquefasciatus")
Into Qry_LarvalAlboDetect
Order by species desc
Commit Table Qry_LarvalAlboDetect As "C:\Users\Public\MOSI\LarvalAlboDetect.tab" TYPE NATIVE Charset "WindowsLatin1" Interactive
Open Table "C:\Users\Public\MOSI\LarvalAlboDetect.tab" Interactive

Add map layer LarvalalboDetect

Set map Layer 1 Global Symbol (41,0,4,"MapInfo Cartographic",1,0)    
LAYER 1 DISPLAY Off
shade 1 with SPECIES values  "Ae aegypti" Symbol (93,255,22,"MapInfo Cartographic",1,0)  ,"Ae albopictus" Symbol (93,16711680,22,"MapInfo Cartographic",257,180),"Cx quincquefasciatus" Brush (2,16711935,16777215) Pen (1,2,0) Line (1,2,16711935) Symbol (93,45056,22,"MapInfo Cartographic",257,0)  default Symbol (40,0,12)

set legend layer 1 display on shades off symbols on lines off count off title auto Font ("Arial",0,9,0) subtitle auto Font ("Arial",0,8,0) ascending on ranges Font ("Arial",0,8,0) auto display off ,auto display on ,auto display on


Thanks for any assistance


Reply all
Reply to author
Forward
0 new messages