1

Delphi 7 で GMLib 1.1.0.00 - Google マップ ライブラリを使用しています。

旅程を作成するには、一連のポイントを道路とともに Google マップに表示する必要があります。

このコードで問題なく動作しますが、各ウェイポイントに特定のアイコンを配置する必要があります。しかし、アイコンを設定する唯一の方法は、WayPointList.icon のプロパティです ...

procedure TfrmMap.FillMarker;
var
i                      : Integer;
sAdr                   : string;
gmllLoc                : TLatLng;
gmMk                   : TMarker;
Count: Integer;
sTitle: string;
const
MAX_REQUEST = 100;
begin
  gmMarker.Clear;
  Count := Min(MAX_REQUEST, recCustomLocS.LocCount);
  for i := 0 to Count - 1 do
  begin

    if(i = 4) then
    begin
      Break;
    end;

    try
      // Build Adress
      sAdr := recCustomLocS.arGMCustomersLocation[i].Country;
      if sAdr <> '' then
      begin
        sAdr := 'Belgium';
      end;
      sAdr := sAdr + ' ' + recCustomLocS.arGMCustomersLocation[i].PostCode + ' '
        + recCustomLocS.arGMCustomersLocation[i].City + ' '
        + recCustomLocS.arGMCustomersLocation[i].Adress;

      // Geolocalize address
      gmGeoCde.Geocode(sAdr);

  case gmGeoCde.GeoStatus of
    gsOK:
      begin
        if gmGeoCde.Count > 0 then
        begin
          gmllLoc := gmGeoCde[0].Geometry.Location;

          // Set Title
          sTitle := recCustomLocS.arGMCustomersLocation[i].CustName;
          if sTitle = '' then
            sTitle := IntToStr(recCustomLocS.arGMCustomersLocation[i].RepairNo);

          // Add direction to map
          if( i = 0) then
          begin
            GmDirection1.DirectionsRequest.Origin.Address :=  sAdr;
          end
          else
          begin
            if(i = 3) then
            begin
              GmDirection1.DirectionsRequest.Destination.Address := sAdr;
            end
            else
            begin
              GmDirection1.DirectionsRequest.WaypointsList.Add.Location.Address := sAdr;
              GmDirection1.DirectionsRequest.WaypointsList.Items[0].DisplayName := 'TEST NICO';
              GmDirection1.DirectionsRequest.WaypointsList.Items[0].StopOver := true;
              GmDirection1.DirectionsRender.MarkerOptions.Icon := sIconGreen;
            end;
          end;
        end;
      end;
  end;
except
  on E: Exception do
    ShowMessage(e.Message);
end;
end;
GmDirection1.Execute;
end;

GMMarkers を使用して別のソリューションを試してみましたが、この手順では各ポイント間の道路を追跡する方法がわかりません。

// Add Marker to map
          gmMk := gmMarker.Add(gmllLoc.Lat,gmllLoc.Lng,sTitle);
          gmMk.MarkerType := mtStandard;

          case recCustomLocS.arGMCustomersLocation[i].color of
            clBlue: gmMk.Icon := sIconBlue;
            clRed: gmMk.Icon := sIconRed;
          else
            gmMk.Icon := sIconGreen;
          end;

          gmMk.OpenCloseInfoWin;
          //TInfoWindow(gmMk.InfoWindow).AutoOpen := True;
          gmMk.InfoWindow.CloseOtherBeforeOpen := True;
          gmMk.ShowInfoWinMouseOver := True;
          //gmMk.InfoWindow.HTMLContent := '<div style=''width:250px;margin:0 0 20px 20px;max-height:90px;''>'
          gmMk.InfoWindow.HTMLContent := '<div style=''width:200px;max-height:90px;''>'
            + ' <b>' + IntToStr(recCustomLocS.arGMCustomersLocation[i].RepairNo) + '</b>'
            + StringOfChar(' ',30 - Length(recCustomLocS.arGMCustomersLocation[i].CustName))
            + '<i> ' + recCustomLocS.arGMCustomersLocation[i].CustName + '</i>'
            + '<br>' + recCustomLocS.arGMCustomersLocation[i].Adress + '<br>'
            + recCustomLocS.arGMCustomersLocation[i].PostCode + ' ' + recCustomLocS.arGMCustomersLocation[i].City
            + '</div>';
            }
        end;

助けてくれてありがとう;)

4

0 に答える 0