TGMDirection脚本错误 [英] TGMDirection Script Error

查看:192
本文介绍了TGMDirection脚本错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用TGMDirection来显示两个标记之间的路线,我点击。
这里是一样的想法,但在Delphi中使用GMLib 1.8:
http: //www.geocodezip.com/inventoresdegaragem_com_dbteste_indexB.html



第一个方向它显示没有任何错误。
当我再次点击另一个标记时,它弹出并显示脚本错误:
行:539
字符:9
错误:无法检索属性的值close:object is null或undefined
代码:0
网址:about:blank



你有任何想法吗?
我使用的代码是:

  procedure TForm1.GMMarker1DblClick(Sender:TObject; LatLng:TLatLng; 
Index:Integer; LinkedComponent:TLinkedComponent);
开始
,如果legcount = 0,则
开始
marker1index:=索引;
legcount:= legcount + 1;
end
else if legcount = 1 then
begin
legcount:= 0;
marker2index:= Index;

GMDirection1.DirectionsRequest.Origin.LatLng:= GMMarker1.Items [marker1index] .Position;
GMDirection1.DirectionsRequest.Destination.LatLng:= GMMarker1.Items [marker2index] .Position;
GMDirection1.Execute;

如果GMDirection1.DirectionsResult [routenr] .Status = dsOK,则
begin

GMDirection1.Free;
end;
routenr:= routenr + 1;
end;
end;


解决方案

InfoWindowCloseAll JavaScript函数中发现了一个错误。你有两个选择来解决这个问题。

1.-容易:在创建标记时,将Marker.InfoWindow.CloseOtherBeforeOpen属性设置为False;



2.-复杂性:您需要修改HTML代码并重新编译资源和组件。为此,请使用文本编辑器(如Notepad ++)打开。\Resources\map.html搜索InfoWindowCloseAll函数并使用以下代码对其进行修改:

<$ p $函数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;
}
}
}
}

保存使用.\Resources\\rc.cmd
更改和编译资源现在,重新编译GMLib组件和您的应用程序



问候


I use TGMDirection to show routes between two markers I click on. It is the same idea like here, but in Delphi using GMLib 1.8: http://www.geocodezip.com/inventoresdegaragem_com_dbteste_indexB.html

First Direction It shows without any error. When I click again on another marker it pop up and Script error: Line: 539 Characters: 9 Error: Can not retrieve the value of the property close: object is null or undefined Code: 0 URL: about: blank

Do you have any Idea ? The code I use is:

procedure TForm1.GMMarker1DblClick(Sender: TObject; LatLng: TLatLng;
Index: Integer; LinkedComponent: TLinkedComponent);
begin
  if legcount = 0 then
  begin
    marker1index :=Index;
    legcount:=legcount+1;
  end
  else if legcount = 1 then 
  begin
    legcount:=0;
    marker2index :=Index;

    GMDirection1.DirectionsRequest.Origin.LatLng := GMMarker1.Items[marker1index].Position;
    GMDirection1.DirectionsRequest.Destination.LatLng := GMMarker1.Items[marker2index].Position;
    GMDirection1.Execute;

    if GMDirection1.DirectionsResult[routenr].Status = dsOK then 
    begin

      GMDirection1.Free;
    end;
    routenr:=routenr+1;
  end;
end;

解决方案

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

这篇关于TGMDirection脚本错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆