Mapping application

We have a marketable product written in Delphi 6 that provides information on various establishments in the UK.  We want to be able to display the set of establishments from a search in a Google style map with flags marking the location of each establishment. with a popup box for each flag that could contain a link either to an external web page or to an internal function within the application that could say display detailed information about the establishment.

I have obtained a javascript using Google Maps which does what I want it to do and can run it in an external web browser.  However, I cannot seem to run it within a Delphi TWebBrowser, which is probably what I would need to do.

Also are there any licencing implications using Google Maps in a commercial application?  If so, what other packages are there that would integrate into Delphi 6.
<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN"  
<html xmlns=""> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/> 
    <title>Google Maps JavaScript API Example</title> 
    <script src=";v=2&amp;key=ABQIAA.....&sensor=false" 
    <script type="text/javascript"> 
    function initialize() { 
      if (GBrowserIsCompatible()) { 

        function createMarker(point,html) {
          var marker = new GMarker(point);
          GEvent.addListener(marker, "click", function() {
          return marker;

        var map = new GMap2(document.getElementById("map_canvas")); 

        map.setCenter(new GLatLng(51.54, -0.136), 12); 

// Add 10 markers to the map at random locations 
        var bounds = map.getBounds(); 
        var southWest = bounds.getSouthWest(); 
        var northEast = bounds.getNorthEast(); 
        var lngSpan = northEast.lng() - southWest.lng(); 
        var latSpan = -; 
        for (var i = 0; i < 10; i++) 
          var point = new GLatLng( + latSpan * Math.random(), 
                southWest.lng() + lngSpan * Math.random()); 
          var marker = createMarker(point,'Some stuff to display in the Info Window')



  <body onload="initialize()" onunload="GUnload()"> 
    <div id="map_canvas" style="width:975px; height: 620px"></div> 

Open in new window

Who is Participating?
Emmanuel PASQUIERFreelance Project ManagerCommented:
I found that strange the need to use a stringlist, and playing a bit it's not needed. I use ANSIString also to avoid problems with Delphi 2009, 2010 unicode strings

WBLoadHTML ( WebBrowser1,
  '<a href="">GOTO</a><b>About Delphi Programming</b>' );
procedure WBLoadHTML(WebBrowser: TWebBrowser; HTMLCode: ANSIString) ;
 ms: TMemoryStream;
 WebBrowser.Navigate('about:blank') ;
 while WebBrowser.ReadyState < READYSTATE_INTERACTIVE do
 if Assigned(WebBrowser.Document) then
   ms := TMemoryStream.Create;
    ms.Write(HTMLCode[1], Length(HTMLCode));
    (WebBrowser.Document as IPersistStreamInit).Load(TStreamAdapter.Create(ms)) ;

Open in new window

Emmanuel PASQUIERFreelance Project ManagerCommented:
I suspect that maybe GBrowserIsCompatible will return false with a TWebBrowser.
Perhaps you can try to not call it and create your markers directly ?
rogerfg7Author Commented:
|I have got it to run by writing the code to a file then calling the WebBrowser Navigate method with the file name.  It does run but slowly (20 seconds as opposed to 5 seconds in IE 8).  Ideally I would like to get the same result but without writing to a file and then loading.  Is there no methods associated with TWebBrowser that would would allow the javascript code to be run directly from Delphi code and the markers to be added on the fly.
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

You don't mention what your database is; however, SQL Server 2008 (Express) has some mapping functionalities.
rogerfg7Author Commented:
We are retrieving the data from Paradox tables, but all the info is stored in objects.  I have the code working correctly now after translating GIS conversion routines into Delphi.  However, I still have to write the javascript to a file on disk and then call WebBrowser.Navigate2 to load the file.  It would be nice to be able to pass the javascript directly to the WebBrowser.
Emmanuel PASQUIERFreelance Project ManagerCommented:
rogerfg7Author Commented:
Thanks.  Works a treat.

I did find a wrapper for TWebBrowser, which allows more Delphi like code

But yours works for what I need.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.