国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

MapX使用數據庫數據添加專題圖(系列之三)

2019-11-18 18:20:21
字體:
來源:轉載
供稿:網友

關鍵字MapX Delphi 專題圖

作者:楊雨田 blue_bat@126.com

 

本文描述了在MapX中添加專題圖的方法,其中MapX中關于添加專題圖的過程語法描述如下(介于英語水平太高,能認識的英文字母大概還有二十多個,實在不愿意打開金山詞霸給大家進行高質量的翻譯,哈哈):
 
OBJECT.Add ([Type], [Field], [Name], [ComputeTheme]) 
 
OBJECT  RePResents a Themes object.
Type   Specifies the type of thematic map to create. This takes a ThemeTypeConstants value. This is an optional parameter, and if not specified (or specified as miThemeAuto), MapX will attempt to choose a good default based on the number of fields passed in as well as what other theme types are already being displayed. If MapX cannot choose a default theme type, an error is generated.
Field(s)   Specifies the field or fields to thematically map. A field can be specified by name, index, or by a Field object. If you are creating a theme using multiple variables (such as a bar chart or pie chart), pass in a Fields collection or an array of field names, indexes, or Field objects. This is an optional parameter, and if not specified, MapX uses the first numeric field of the Dataset.
Name   Specifies the name of the thematic map. This is a String parameter. This is an optional parameter, and if not specified, MapX generates a name such as StatesBySales.
ComputeTheme  Boolean. The default value is True which will calculate the theme from the table data. If the value is set to False an invisible theme object will be created with 10 ranges for IndividualValue themes and 5 ranges for Ranged themes. You can then manually set the minimum and maximum values to define the theme with Theme.DataMin and Theme.DataMax. For ranged themes you can manually set the theme ranges or calculate equal size ranges determined by the minimum (Theme.DataMin) and maximum (Theme.DataMax) values.
 
關于專題圖的風格共有以下幾種:
        miThemeRanged  = 0 
        miThemeBarChart = 1 
        miThemePieChart = 2 
        miThemeGradSymbol = 3 
        miThemeDotDensity = 4 
        miThemeIndividualValue = 5 
        miThemeAuto = 6 
        miThemeNone = 9
具體都是什么樣,請自己寫代碼看看,哈哈
 
下面是我寫的部分代碼:
unit Main;
 
interface
 
uses
  Windows, Messages,{略去一部分} SysUtils, Variants, Classes;
 
type
  TfrmMain = class(TForm)
    mapMain: TMap;                      {地圖控件}
  private
    { Private declarations }
    ThemesList : TStringList;           {用來保存多個專題圖的名稱列表}
  public
    { Public declarations }
    procedure ToAddThemes(style : integer; TheName : string);   {添加專題圖}
    procedure ToDeleteThemes;           {刪除專題圖}
  end;
 
var
  frmMain: TfrmMain;
 
implementation
 
{$R *.dfm}
 
{略去其他功能代碼}
 
 
{
        添加專題圖,參數style表示專題圖風格,TheName表示圖例標題
}
procedure TfrmMain.ToAddThemes(style : integer; TheName : string);
  function DefaultName : string;{用來生成一唯一的名稱}
  begin
    {我用的方法是取一個當前時間,兩次調用本函數的時間間隔應該不會少于0.5秒,
     所以這個方法在這個項目中可以取得唯一的名稱}
    Result := 'YYT' + FormatDateTime('YYYYMMDDHHNNSSzzz',now);
  end;
var
  flds : array of string;       {字段列表}
  oBLayer : BindLayer;          {綁定圖層}
  ds : Dataset;                 {MapX數據集}
  i : integer;                  {循環變量}
  thm : theme;                  {MapX專題圖}
  str : string;                 {用于保存字符串}
begin
  {aqThemes可以是一個ADOQuery或者ADOTable,我使用的是ADOQuery。
   在這個ADOQuery中前四個字段分別是:
     ID(唯一的數字或者字符串,一般為編號),
     NAME(字符串,要素的標簽),
     X(浮點數,要素的經度或者橫坐標),
     Y(浮點數,要素的緯度或者縱坐標)。
   后面的其它字段都是數字類型,用來表示相關的數據。
    
    ◎請參考我的文章《從數據庫繪制MapX圖層(二)》,
    url是http://dev.csdn.net/article/31/31719.shtm
   }
  if not aqThemes.Active then
  begin
    dmData.GiveMsg('系統基礎表沒有打開!');
    exit;
  end;
  try
    {取一個唯一的名字,}
    str := DefaultName;
 
    {設置綁定圖層的屬性}
    oBLayer := coBindLayer.Create;
    progress.StepPlus(2);
    oBLayer.LayerName := str;
    oBLayer.LayerType := miBindLayerTypeXY;
    oBLayer.RefColumn1 := 'X';
    oBLayer.RefColumn2 := 'Y';
 
    {下面的調用和我在《從數據庫繪制MapX圖層(二)》使用的方法一樣,
     請參考我的那篇文章,url是http://dev.csdn.net/article/31/31719.shtm}
 
    ds := mapMain.Datasets.Add(12,
                               aqThemes.Recordset,
                               str,
                               'ID',
                               EmptyParam,
                               oBLayer,
                               EmptyParam,
                               EmptyParam);
    {組織專題圖現實的數據字段,存儲在字符串數組中}
    SetLength(flds,aqThemes.Fields.Count - 3);
    for i:=3 to aqThemes.Fields.Count - 1 do
    begin
      flds[i - 3] := aqThemes.Fields.Fields[i].FieldName;
    end;
    {實際添加專題圖的過程}
    thm := ds.Themes.Add(style,flds,DefaultName,EmptyParam);
    {設置專題圖圖例標題}
    thm.Legend.Title := TheName;
    {記錄新添加的專題圖名稱}
    ThemesList.Add(str);
    {btnDeleteThemes是一個在本窗口上的按鈕,用來刪除專題圖,
     添加專題圖后就將他顯示出來,如果刪除了全部專題圖就將他隱藏}
    btnDeleteThemes.Visible := true;
  except
    GiveMsg('創建專題圖失敗!');{自定義過程,給出出錯提示}
  end;
end;
 
{
        刪除專題圖,我采用的方法是刪除所有專題圖
}
procedure TfrmMain.ToDeleteThemes;
var
  i : integer;  {循環變量}
begin
  for i:=0 to ThemesList.Count-1 do{循環所有添加了的專題圖}
  begin
    {刪除數據集}
    mapMain.Datasets.Remove(ThemesList.Strings[i]);
    {刪除專題圖}
    mapMain.Layers.Remove(ThemesList.Strings[i]);
    {如果只想刪除某一個專題圖,不用循環就行了}
  end;
  {此時已經沒有專題圖了,將刪除專題圖按鈕隱藏}
  btnDeleteThemes.Visible := false;
  {清除專題圖名稱列表}
  ThemesList.Clear;
end;
 
//...
 
end.

上一篇:一種利用EXCEL快速寫SQL語句的方法

下一篇:從數據庫繪制MapX地圖(二)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 天津市| 郑州市| 广元市| 青浦区| 新闻| 新晃| 岚皋县| 衡山县| 扎兰屯市| 库车县| 休宁县| 永福县| 深水埗区| 安陆市| 潮安县| 岚皋县| 六枝特区| 三穗县| 新郑市| 阿克苏市| 旅游| 博白县| 寿宁县| 东城区| 花垣县| 定州市| 泰安市| 通海县| 集贤县| 高密市| 达尔| 丰原市| 五莲县| 延寿县| 明水县| 永济市| 五常市| 邵武市| 峨眉山市| 自贡市| 台中县|