Google Maps geocoding service with TWebBrowser

1509 views
Skip to first unread message

Koen

unread,
Jul 8, 2008, 4:50:58 PM7/8/08
to
Hi,
I want to use the Google geocoding service to turn a regular streetaddress
into coordinates & last but not least show a map of the location in an
embeded TWebBrowser component on my form..
I found some articles on the subject but I am looking for a working Delphi
example.
Anybody any ideas?
Regards,
Koen

Gaetan Siry

unread,
Jul 9, 2008, 1:13:07 AM7/9/08
to

There is an interesting thread on Marco Cantu's site

http://blog.marcocantu.com/blog/google_map_delphi_server.html


Koen

unread,
Jul 9, 2008, 1:48:02 AM7/9/08
to
Yes I know.. but it is not very in-depth & it lacks full-source code
examples..
Most examples I found on the net create a so-called 'marker' on a map and
that is it..
I am looking for an example using the geocoding API transforming a given
streetaddress (streetname, placename, ZIP) into coordinates first.. (as in a
route-planner)
Regards,
Koen

"Gaetan Siry" <g...@g.com> schreef in bericht
news:487448e3$1...@newsgroups.borland.com...

Jim P

unread,
Jul 9, 2008, 3:41:28 PM7/9/08
to
Koen wrote:
> Yes I know.. but it is not very in-depth & it lacks full-source code
> examples..
> Most examples I found on the net create a so-called 'marker' on a map
> and that is it..
> I am looking for an example using the geocoding API transforming a given
> streetaddress (streetname, placename, ZIP) into coordinates first.. (as
> in a route-planner)
> Regards,
> Koen
>
and you expect to find all of this code simply laying around - - - -

first you need to know the location of the streets - - - and how they
lay on the world - - where they are on the world - - no formula is
present for that - - no code is present for that - - -

this is a data base problem - - -
Do you expect to find this set of data simply laying around - - after
all of the work that it takes to get this information and then make sure
that the information is right - - - cities do not have this accurate.
Streets are blocked off for years but are still in the city road maps.
and published maps. Roads run differently than planned - - built as is
different than design.

Blocks are not xxx feet long - - etc.

Jim P.

Marc Rohloff [TeamB]

unread,
Jul 9, 2008, 4:27:51 PM7/9/08
to
On Tue, 8 Jul 2008 22:50:58 +0200, Koen wrote:

> I want to use the Google geocoding service to turn a regular streetaddress
> into coordinates & last but not least show a map of the location in an
> embeded TWebBrowser component on my form..

You probably wouldn't want to use the TWebBrowser to access the
GeoCoding API since you don't want to display the results.
Use something else like the Indy or Synapse components to perform an
http request to Google's GeoCoding service then take the result and
build the web page to show the map.

--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com

Koen

unread,
Jul 10, 2008, 4:12:24 AM7/10/08
to
Indeed.. got an example somewhere showing how to do that?
The HTTP result is a CSV or XML file..
Both are easy to interprete; the result holds the coordinates needed to
request the map..

"Marc Rohloff [TeamB]" <ma...@nospam.marcrohloff.com> schreef in bericht
news:jjrfpcd7als7$.dlg@dlg.marcrohloff.com...

Koen

unread,
Jul 10, 2008, 4:14:02 AM7/10/08
to
My goal is to make a Delphi component one can drop on a form showing a map
for a given streetaddress.

"Koen" <pls_do_not_mail_me@no_spam.eu> schreef in bericht
news:4873d36b$1...@newsgroups.borland.com...

Koen

unread,
Jul 10, 2008, 4:15:57 AM7/10/08
to
Why not.. Stefan Cruysberghs wrote a good article on the subject (in dutch /
see www.scip.be).
He programmed it in C#.NET (see the screenshots placed on his website) so I
guess some Delphi code must be around too no? Offcourse I can try to figure
it out by my self but that takes time; I had hoped to find more information
here..
The geocode API takes a streetaddress (using HTTP? / As entered in a
browser) and returns a CSV/XML file with coordinates and other information..
The coordinates returned be passed to another Google API to get a map of the
area..
Regards,
Koen


"Jim P" <Ji...@mad.scientist.com> schreef in bericht
news:4875146a$1...@newsgroups.borland.com...

Jim P

unread,
Jul 10, 2008, 12:43:47 PM7/10/08
to
OK

So you want to freely use Google for your own product?

what makes you think that they are going to want to have you make
a product that uses their collected information for free

right now they collect ad money for this service. What will they collect
from your use of their information and service?

Jim P

Mark Tiede

unread,
Jul 10, 2008, 2:44:33 PM7/10/08
to
Jim,

As I recall, Google was encouraging such use.


"Jim P" <Ji...@mad.scientist.com> wrote in message
news:48763c46$1...@newsgroups.borland.com...

Koen

unread,
Jul 11, 2008, 6:15:25 AM7/11/08
to
So you are saying.. let us invent the wheel and do not use it?

They allow the service to be used within certain limits..
And if they charge money for it.. then it is up to the end-user/customer to
decide if he wants to pay for it or not..

Regards,
Koen

"Jim P" <Ji...@mad.scientist.com> schreef in bericht

news:48763c46$1...@newsgroups.borland.com...

Deli Soetiawan

unread,
Jul 11, 2008, 8:57:00 AM7/11/08
to
i think it could be done, but sorry i can only give some algo
1. use http post to post street address into google maps website
example :
http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=10+market+st,+san+francisco&btnG=Search+Maps
(where as "10 market st, san francisco" as sample address)

2. use HTML page scraping technique, to scrap result map (image address on
the result page), since you need the address you can scrap it from it http
result page
voila you get this :
http://mt0.google.com/mt?n=404&v=w2.75&hl=en&x=10486&s=&y=25325&zoom=1&s=Galileo
notice you get coordinate x=10486, y=25325

3. now convert x and y into standar coordinate (longitude and latitude),
you can use many sample workaround to do this (marco cantu convert
longitude and latitude into x,y and i think you can reverse it)
i forgot where i get the google map sample, but if i get it, i'll post it
soon

4. work almost done here :D

btw there was a problem, the coordinate taken was 1 x,y i dunno that would
be help, but good as a start
if you know where the csv or xml outputed (in url) that would be different
story

have fun

On Fri, 11 Jul 2008 17:15:25 +0700, Koen <pls_do_not_mail_me@no_spam.eu>
wrote:

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Jason Penny

unread,
Jul 18, 2008, 9:41:22 AM7/18/08
to
I put together a little test program to do just this,
it shows a webpage with a map in the TWebBrowser, and uses a TIdHTTP to
geocode the entered address

I started from
http://www.stevetrefethen.com/blog/UsingGoogleMapsFromAWindowsClientApplication.aspx

see GoogleMapsTest at http://jasontpenny.com/Delphi/, there's a screenshot
and a zip of the project.


to test it, you can enter your API key in the GOOGLE_MAPS_API_KEY const or
choose the "cheat" radiobutton, which scrapes the map webpage that entering
an address in http://maps.google.com would return (which doesn't require an
API key)

"Koen" <pls_do_not_mail_me@no_spam.eu> wrote in message
news:4873d36b$1...@newsgroups.borland.com...

Reply all
Reply to author
Forward
0 new messages