图文解说ChinaCock高德地图组件-显示多个标注(四)(Graphic interpretation chinacock Gaode map component – display multiple annotations (IV))

前文介绍了如何在地图上通过设置标注来采集位置的经纬度,当用户采集了多个实体的位置信息后,我们就可以在地图上一次性显示这些实体的标注了!

基于前文,接下来在地图上的做标注就很简单了,可以复用以前的代码,具体参阅:图文解说ChinaCock高德地图组件采集坐标 (二)

接下来,我们再做一个过程:

procedure TMarkerMapFrame.MarkerAll;
var
  mk: TCCuniGUIAMap.TMarker;
begin
  with UniMainModule do
  begin
    q.Close;
    q.Query.Text := '你的查询语句';
    q.Open;

    q.First;
    while not q.Eof do
    begin
      mk := AddMarker(q.FieldByName('FJD').AsFloat, q.FieldByName('FWD').AsFloat, q.FieldByName('FName').AsString);

      if (q.FieldByName('FJD').AsString <> '') and (q.FieldByName('FJD').AsString <> '') then
      begin
        mk:=  AddMarker(q.FieldByName('FJD').AsFloat, q.FieldByName('FWD').AsFloat, q.FieldByName('FName').AsString);
       mk.CustomParams.Values['name']:=q.FieldByName('FName').AsString;
      end;
      q.Next;
    end;
  end;
  // 适应地图对象 让所有对象都在地图最佳区域内
  self.CCuniGUIAMap1.SetFitView(True);

end;

该过程,通过查询一个TDataSet并循环这个数据集,在循环过程中调用AddMarker方法,在地图上画出每个实体的标注。

画完所有的标注,调用地图的SetFitView方法,让所有的标注点正好都显示在地图上。

同样,基于前文,可以实现当用户鼠标移动到一个标注时显示他的名称,但问题来了,如果用户想了解一个标注点时,如何支持呢?

这里,我是这样实现的,就是当用户在一个标注点上单击鼠标,隐藏原来的名称标签,换成一个大的标签来显示详细信息。

在实现的过程中,测试了两种方案,都可以满足上面的需求,接下来,分别介绍这两种方案的实现过程:

一、纯Delphi实现方式

利用一个uniPanel组件,基于他设计详细的显示内容,注意这里的优点,就是可视化的设计这个Panel,发挥想象,你可以放置任意你想放置的可视控件进去。

二、标签实现方式

基于地图控件的Text属性来显示详细内容,与前文的实现,利用标签Text对象显示标注的名称是一样的过程,只不过这里显示更多的内容。这种方式的优点是完全与地图集成一体,运行效率效率高。

————————

The previous article introduced how to collect the longitude and latitude of the location by setting labels on the map. When the user collects the location information of multiple entities, we can display the labels of these entities on the map at one time!

Based on the above, it’s easy to mark on the map. You can reuse the previous code. For details, see: graphic interpretation of chinacock Gaode map component collection coordinates (II)

Next, let’s do another process:

procedure TMarkerMapFrame.MarkerAll;
var
  mk: TCCuniGUIAMap.TMarker;
begin
  with UniMainModule do
  begin
    q.Close;
    q.Query.Text := '你的查询语句';
    q.Open;

    q.First;
    while not q.Eof do
    begin
      mk := AddMarker(q.FieldByName('FJD').AsFloat, q.FieldByName('FWD').AsFloat, q.FieldByName('FName').AsString);

      if (q.FieldByName('FJD').AsString <> '') and (q.FieldByName('FJD').AsString <> '') then
      begin
        mk:=  AddMarker(q.FieldByName('FJD').AsFloat, q.FieldByName('FWD').AsFloat, q.FieldByName('FName').AsString);
       mk.CustomParams.Values['name']:=q.FieldByName('FName').AsString;
      end;
      q.Next;
    end;
  end;
  // 适应地图对象 让所有对象都在地图最佳区域内
  self.CCuniGUIAMap1.SetFitView(True);

end;

In this process, query a tdataset and cycle the data set. During the cycle, call the addmarker method to draw the annotation of each entity on the map.

After drawing all the labels, call the setfitview method of the map to make all the label points appear on the map.

Similarly, based on the above, you can display the user’s name when the user moves the mouse to a dimension, but the problem comes. If the user wants to know a dimension point, how can it be supported?

Here, I realize it in this way, that is, when the user clicks on a label point, hide the original name label and replace it with a large label to display detailed information.

In the process of implementation, two schemes are tested, which can meet the above requirements. Next, the implementation processes of these two schemes are introduced respectively:

1、 Pure Delphi implementation

Use a unipanel component to design detailed display content based on it. Pay attention to the advantage here, that is, visually design the panel, give play to your imagination, and you can place any visual control you want to place.

2、 Label Implementation

Displaying the detailed content based on the text attribute of the map control is the same process as the previous implementation of using the label text object to display the label name, but more content is displayed here. The advantage of this method is that it is fully integrated with the map and has high operation efficiency.