TGMDirection Script Error

别说谁变了你拦得住时间么 提交于 2019-12-06 16:48:39

I have found a bug into the InfoWindowCloseAll JavaScript function. You have two options to solve this problem.

1.- The easy: when you create the markers, put the Marker.InfoWindow.CloseOtherBeforeOpen property to False;

2.- The complex: you need to modify the HTML code and recompile resources and components. For do this, open the .\Resources\map.html with a text editor (like Notepad++) search the InfoWindowCloseAll function and modify it with this code:

function InfoWindowCloseAll() {
  for (i = 0; i < linkedCompList.length; i++) {
    if (linkedCompList[i] instanceof google.maps.InfoWindow) {
      linkedCompList[i].close();
      linkedCompList[i].GMLibIWIsOpen = false;
    }
    else {
      if (!(linkedCompList[i] instanceof google.maps.DirectionsRenderer)) {
        linkedCompList[i].GMLibInfoWin.close();
        linkedCompList[i].GMLibInfoWin.GMLibIWIsOpen = false;
      }
    }
  }
}

Save changes and compile resources with .\Resources\rc.cmd Now, recompile GMLib components and your application

Regards

To do this is very easy. You need 3 GMLib components (a TGMMap, a TGMMarker and a TGMDirection) and a TWebBrowser linked together. Set to false the GMDirection1.HiddeOthers property and into the OnClick GMMap event put this lines of code

procedure TForm1.GMMap1Click(Sender: TObject; LatLng: TLatLng; X, Y: Real);
begin
  GMMarker1.Add(LatLng.Lat, LatLng.Lng);
  if GMMarker1.Count mod 2 = 0 then
  begin
    GMDirection1.DirectionsRequest.Origin.LatLng.Assign(GMMarker1[GMMarker1.Count -   2].Position);
    GMDirection1.DirectionsRequest.Destination.LatLng.Assign(GMMarker1[GMMarker1.Count - 1].Position);
    GMDirection1.Execute;
  end;
end;

And that is all ;-)

Regards

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!