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"  
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/> 
    <title>Google Maps JavaScript API Example</title> 
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAA.....&sensor=false" 
            type="text/javascript"></script> 
    <script type="text/javascript"> 
 
    function initialize() { 
      if (GBrowserIsCompatible()) { 

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

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

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

// 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 = northEast.lat() - southWest.lat(); 
        for (var i = 0; i < 10; i++) 
	{ 
          var point = new GLatLng(southWest.lat() + latSpan * Math.random(), 
                southWest.lng() + lngSpan * Math.random()); 
          var marker = createMarker(point,'Some stuff to display in the Info Window')
          map.addOverlay(marker); 
        }        

      } 

    } 

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

Open in new window

rogerfg7Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 ?
0
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.
0
8080_DiverCommented:
You don't mention what your database is; however, SQL Server 2008 (Express) has some mapping functionalities.
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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.
0
Emmanuel PASQUIERFreelance Project ManagerCommented:
0
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="http://delphi.about.com">GOTO</a><b>About Delphi Programming</b>' );
procedure WBLoadHTML(WebBrowser: TWebBrowser; HTMLCode: ANSIString) ;
var
 ms: TMemoryStream;
begin
 WebBrowser.Navigate('about:blank') ;
 while WebBrowser.ReadyState < READYSTATE_INTERACTIVE do
  Application.ProcessMessages;
 if Assigned(WebBrowser.Document) then
  begin
   ms := TMemoryStream.Create;
   try
    ms.Write(HTMLCode[1], Length(HTMLCode));
    ms.Position:=0;
    (WebBrowser.Document as IPersistStreamInit).Load(TStreamAdapter.Create(ms)) ;
   finally
     ms.Free;
   end;
  end;
end;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rogerfg7Author Commented:
Thanks.  Works a treat.

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

http://www.delphidabbler.com/articles?article=14&part=1#stage1-docload

But yours works for what I need.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.