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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
const
GoogleMapsPage: String =
'<html> '+
'<head> '+
'<meta name="viewport" content="initial-scale=1.0, user-scalable=yes" /> '+
'<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> '+
'<script type="text/javascript"> '+
' var map;'+
' function initialize() { '+
// partie pour se positionner en fonction d'une adresse
' geocoder = new google.maps.Geocoder();'+
' geocoder.geocode( { ''address'': [Adresse]}, function(results, status) {'+
' map.setCenter(results[0].geometry.location);'+
' var marker = new google.maps.Marker({map: map,position: results[0].geometry.location});'+
' });'+
// partie pour mettre un marqueur en fonction d'une latitude longitude récupérée
' var latlng = new google.maps.LatLng([Lat],[Lng]); '+
' var myOptions = { '+
' zoom: 12, '+
' center: latlng, '+
' mapTypeId: google.maps.MapTypeId.[Type] '+
' }; '+
// affichage de la map
' map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); '+
' var marker = new google.maps.Marker({'+
' position: latlng, '+
' title: "[Title]", '+
' map: map '+
' });'+
' } '+
''+'</script> '+
'</head> '+
'<body onload="initialize()"> '+
' <div id="map_canvas" style="width:100%; height:100%"></div> '+
'</body>'+
'</html>';
.....
// Utilisation
procedure TFormCarte.Button1Click(Sender: TObject);
var MapStr : String;
function ReplaceTag(const PageStr,Tag,NewValue:string):String;
begin
Result:=StringReplace(PageStr,Tag,NewValue,[rfReplaceAll]);
end;
begin
MapStr:=OpenStreetMapsPage;
MapStr:=ReplaceTag(MapStr,'[Adresse]',QuotedStr('14 rue du moulinier 44115 HAUTE GOULAINE')); // test par adresse
// test position connue
MapStr:=ReplaceTag(MapStr,'[Lat]','45.8518378');
MapStr:=ReplaceTag(MapStr,'[Lng]','1.1587193');
MapStr:=ReplaceTag(MapStr,'[Title]','Danse Azur SARL');
MapStr:=ReplaceTag(MapStr,'[Type]','HYBRID');
WebBrowser1.LoadFromStrings(MapStr,'');
end; |
Partager