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