Bonjour,
Dans mon application, J'ai un script contenu dans une page HTML sous forme de String.
Ce script comprend une fonction ShowMap avec 4 paramètres string.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  strHTML: String =
  '<!DOCTYPE html>' +
  '<html>' +
  '<head>' +
  '<meta charset="utf-8" />' +
  '<title>Esri Leaflet Quickstart</title>' +
  ' <meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />' +
  '<!-- Load Leaflet from PC -->' +
  '<link rel="stylesheet" href="D:/Developement/CPS-NG/Win64/Debug/Leaflet/leaflet.css"' +
    'integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="' +
    'crossorigin=""/>' +
  '<script src="D:/Developement/CPS-NG/Win64/Debug/Leaflet/leaflet.js"' +
    'integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="' +
    'crossorigin=""></script>' +
  '<style>' +
    'body { margin:0; padding:0; }' +
    '#map { position: absolute; top:0; bottom:0; right:0; left:0; }'+
  '</style>' +
  '</head>' +
 '<body>' +
 '<div id="map"></div>' +
 '<script>' +
    'function ShowMap(MaxLat, MaxLon, MinLat, MinLon)' +
    '{' +
    'var map = L.map("map").fitBounds(' +
    '[MaxLat, MaxLon],' +
    '[MinLat, MinLon]' +
	  ');' +
    'L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png","' +
     '{"' +
    'attribution: "&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> CPS-NG"' +
    '}).addTo(map);' +
    '}' +
 '</script>' +
 '</body>' +
 '</html>';
la fonction de ce script est appelée par une procedure (PlotMap)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
procedure TfrmFlightMap.plotMap;
var
  MaxLat,
  MaxLon,
  MinLat,
  MinLon :String;
begin
  MaxLat:= '51';
  MaxLon:= '5';
  MinLat:= '48';
  MinLon:= '-75';
 
  HTMLWindow2.execScript(Format('ShowMap(%s,%s,%s,%s)',[MaxLat, MaxLon,
                                                        MinLat, MinLon]),
                                                        'JavaScript')  ;
end;
HTMLWindow2 est défini ici:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
procedure TfrmFlightMap.FormCreate(Sender: TObject);
var
  aStream : TMemoryStream;
begin
  wbbMap.Navigate('about:blank');
 
 if Assigned(wbbMap.Document) then
  begin
    aStream :=  TMemoryStream.Create;
    try
      aStream.WriteBuffer(Pointer(strHTML)^, Length(strHTML));
        aStream.Seek(0, soFromBeginning);
        (wbbMap.Document as IPersistStreamInit).Load(TStreamAdapter.
                                                          Create(aStream));
    finally
      aStream.Free;
    end;
    HTMLWindow2:= (wbbMap.Document as iHTMLDocument2).parentWindow;
    wbbMap.Visible:= true;
  end;
end;
Lorsque je lance PlotMap, J'obtiens une erreur de script: ShowMap est indéfini.

Pourriez vous m'aider à comprendre où se situe mon ou mes erreurs?

Merci
Cordialement
Pierre