On Jan 29, 2:14 pm, David Rutten <[email protected]> wrote:
> How can I communicate between my desktop application and the Maps
> applet?

I am not sure that this belongs in this group, but as there is no
group for GM desktop applications I suppose it's OK.

I've tried this with Delphi, and I worked out a very simple, (possibly
primitive), communication system.

Go to any map page, for example
http://maps.forum.nu/gm_main.html
and after the page has loaded, in the browser's address bar type the
following:
javascript:map.zoomIn()

and hit enter.
In the page above, the GMap2 object is called 'map' and it is global,
therefore the command works.

Now, you can do the same in your desktop application, with the Web
Browser control, for example:
webBrowser.Navigate('javascript:map.zoomIn()');

'webBrowser' is an instance of TWebBrowser in Delphi, and TWebBrowser
is a control that encapsulates the version of Internet Explorer
currently installed on your system.

However, you can not send commands the other way, from the javascript
to the desktop application, so you have to make it such that you have
the information you'll need to get from the map, available in global
variables that you can read.
For example, to read the location of a mouse click on the map you'd
have a click event handler that puts the location of the click in a
global variable, *** as strings ***, not as a GLatLng object, and then
using the same technique as above you can call a function that returns
the value of that variable.

That function would write a hidden div with the value of the variable
you want to read, to the source of the document, using document.write
(), and then you'd read the webBrowser.Document property and parse its
contents to obtain the value of the variable.

It's not simple, but it can be done, of course. ;-)

--
Marcelo - http://maps.forum.nu
--




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to