Google Maps

Google Maps

Postby Randal » Wed Dec 12, 2007 2:17 pm

All,

Does anyone have a sample of how to search Google Maps for an address from within a fwh program?

Thanks,
Randal Ferguson
Randal
 
Posts: 260
Joined: Mon Oct 24, 2005 8:04 pm

Postby Antonio Linares » Wed Dec 12, 2007 2:29 pm

Randal,

This is a working sample developed by JL Capel:
Code: Select all  Expand view  RUN
// Radios and WHEN on a GET

#INCLUDE "FIVEWIN.CH"

FUNCTION MAIN()

   LOCAL oDlg, oRadio1, oGet1, obtn
   LOCAL cCurrency := "USD    "
   LOCAL nOption := 1

   DEFINE DIALOG oDlg                                       ;
      FROM 1, 1 TO 10, 30

   @ 1, 1 RADIO oRadio1 VAR nOption OF oDlg  UPDATE         ;
      PROMPT "Estatua Libertad ", "Fortaleny - Valencia - EspaÒa", "Torre Eiffel - ParÌs "

   @ 3, 1 BUTTON oBtn PROMPT "Ver el Mapa" ACTION VerMapa (oDlg, nOption)

   ACTIVATE DIALOG oDlg CENTERED

RETURN NIL

Function VerMapa( oDlgp, nMapa )
local ownd, oactivex



          LOCAL cHtml
       LOCAL nLat, nLon, nZoom

        DO CASE
           CASE nMapa == 1
                nLat := 48.858333
                nLon := 2.295000
                nZoom := 20
           CASE nMapa == 2
                nLat := 39.183994491715936
                nLon := -0.31486988067626952
                nZoom := 18
           CASE nMapa == 3
                nLat := 40.689360
                nLon := -74.044400
                nZoom := 20
         ENDCASE

        cHtml := [   <html> <head> ]+CRLF
        cHtml += [   <meta http-equiv="content-type" content="text/html; charset=utf-8"/> ]+CRLF
        cHtml += [   <title>Google Maps</title> ]+CRLF
        cHtml += [   <script src="http://maps.google.com/maps?file=api&v=2&key=1223" type="text/javascript"></script> ]+CRLF
        cHtml += [   <script type="text/javascript"> ]+CRLF
        cHtml += "   //<![CDATA[ " +CRLF
        cHtml += "   function load() "+CRLF
        cHtml += "   { if (GBrowserIsCompatible()) "+CRLF
        cHtml += [   { var map = new GMap2(document.getElementById("map"),G_SATELLITE_TYPE); ] + CRLF
        cHtml += "   map.addControl(new GLargeMapControl()); "+CRLF
        cHTML += "   map.addControl(new GMapTypeControl());  "+CRLF
        cHTML += "   map.addControl(new GOverviewMapControl()); "+CRLF
        cHTML += "   map.setCenter(new GLatLng(<<<LAT>>>, "+CRLF
        CHTML += "   <<<LONG>>>),<<<ZOOM>>>); "+CRLF
        CHTML += "   map.setMapType(G_HYBRID_TYPE); "+CRLF
        CHTML += "   } } "+CRLF
        CHTML += "   //]]> </script> </head> "+CRLF
        CHTML += [   <body scroll="no" bgcolor="#CCCCCC" topmargin="0" leftmargin="0" ] +CRLF
        CHTML += [   onload="load()" onunload="GUnload()"> ] + CRLF
        chtml += [   <div id="map" style="width:450px;height:300px"></div> ] + CRLF
        chtml += [   </body> </html> ]

        cHtml := STRTRAN(cHtml, "<<<LONG>>>",STR(nLon) )
        cHtml := STRTRAN(cHtml, "<<<LAT>>>",STR(nLat) )
        cHtml := STRTRAN(cHtml, "<<<ZOOM>>>",STR(nZoom) )



        MemoWrit("mihtml.htm",chtml)





   DEFINE WINDOW oWnd TITLE "FiveWin ActiveX Support"



   oActiveX = TActiveX():New( oWnd, "Shell.Explorer.2" )

   oWnd:oClient = oActiveX // To fill the entire window surface

   oActiveX:Do("Navigate2",(CurDrive() + ":\"+CurDir()+"\MiHtml.htm"))

   ACTIVATE WINDOW oWnd
RETUR NIL
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Wed Dec 12, 2007 2:48 pm

Hello Antonio,
Thank you for this post and many thanks to JL Capel.
Is there an easy way to get the
latitude and longitude from a given town name ?
Thanks in advance,
Otto
User avatar
Otto
 
Posts: 6337
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Wed Dec 12, 2007 2:52 pm

Otto,

I don't know, you may search in google :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Randal » Wed Dec 12, 2007 3:57 pm

Antonio,

Thanks for the sample. I did search the forum and had found this sample however I need to be able to show a map based on an address, not lat/lon coordinates. I think the Google API has a method for returning the lat/lon coordinates for a given address. Unfortunately, I don't know enough about java to write a program to do this and I could not find a method for just showing a map based on the address.

Thanks,
Randal
Randal
 
Posts: 260
Joined: Mon Oct 24, 2005 8:04 pm

Postby Barry O'Brien » Wed Dec 12, 2007 4:18 pm

Hi Randal,

I don't know anything about the google maps interface but going back a few months I was under the impression it only worked on lat\long co-ordinates.

The last company I worked for had to buy a data set for all UK addresses which also had all the lat\long co-ordinates in it. This way they could just do a database lookup using the address to get the lat\long co-ordinates to then do the google maps lookup.

I wasn't involved in the development of this unfortunately so I can't tell you any more about how it worked. In any case I would imagine the google maps api has moved on since then!

Kind regards,

Barry
Barry O'Brien
 
Posts: 9
Joined: Tue Aug 28, 2007 9:09 am
Location: Oxford, England

Postby Randal » Wed Dec 12, 2007 5:13 pm

Barry,

It appears there is a method for this:

getLatLng(address, callback)
Sends a request to Google servers to geocode the specified address. If the address was successfully located, the user-specified callback function is invoked with a GLatLng point. Otherwise, the callback function is given a null point. In case of ambiguous addresses, only the point for the best match is passed to the callback function. (Since 2.55)

Thanks,
Randal

Barry O'Brien wrote:Hi Randal,

I don't know anything about the google maps interface but going back a few months I was under the impression it only worked on lat\long co-ordinates.

The last company I worked for had to buy a data set for all UK addresses which also had all the lat\long co-ordinates in it. This way they could just do a database lookup using the address to get the lat\long co-ordinates to then do the google maps lookup.

I wasn't involved in the development of this unfortunately so I can't tell you any more about how it worked. In any case I would imagine the google maps api has moved on since then!

Kind regards,

Barry
Randal
 
Posts: 260
Joined: Mon Oct 24, 2005 8:04 pm

Postby Rafael Clemente » Wed Dec 12, 2007 10:13 pm

Otto, Randal:
If you send me your email I can send you one working sample
Rafael
User avatar
Rafael Clemente
 
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Postby Randal » Wed Dec 12, 2007 10:41 pm

Rafael Clemente wrote:Otto, Randal:
If you send me your email I can send you one working sample
Rafael


You can send that to swtechsup@yahoo.com

Thank you very much!

Randal Ferguson
Randal
 
Posts: 260
Joined: Mon Oct 24, 2005 8:04 pm

Postby RAMESHBABU » Thu Dec 13, 2007 2:26 am

Mr.Rafael

Please share it with me also.

aksharasoft@hotmail.com

Regards

- Ramesh Babu P
Last edited by RAMESHBABU on Thu Dec 13, 2007 5:46 pm, edited 1 time in total.
User avatar
RAMESHBABU
 
Posts: 625
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby Otto » Thu Dec 13, 2007 8:13 am

Thank you Rafael.
Here is my email:
datron@aon.at
User avatar
Otto
 
Posts: 6337
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Thu Dec 13, 2007 8:14 am

Rafael,

Would you mind to post the example source code here ? many thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Rafael Clemente » Thu Dec 13, 2007 1:08 pm

Antonio:
This is the demo code:
#include "FiveWin.ch"

Function Main()
Local oDlg
Local cStreet := Padr("BROADWAY 500", 40)
Local cCity := Padr("NEW YORK CITY", 40)
Local cCountry := Padr("USA", 40)

Define Dialog oDlg From 0,0 To 12,45 Title "Google Maps test"
oDlg:lHelpIcon := .F.
@ 1,3 Say "Street and number:" Of oDlg Size 50,10
@ 1,8 Get cStreet Of oDlg Size 100,10 Picture "@K!"
@ 2,3 Say "City:" Of oDlg Size 50,10
@ 2,8 Get cCity Of oDlg Size 100,10 Picture "@K!"
@ 3,3 Say "Country:" Of oDlg Size 50,10
@ 3,8 Get cCountry Of oDlg Size 100,10 Picture "@K!"
@ 4,11 Button "Search" Of oDlg Action Posicion(Alltrim(cStreet)+"; "+AllTrim(cCity)+"; "+Alltrim(cCountry))
Activate Dialog oDlg Center
Return Nil

DLL FUNCTION Posicion( cTxt AS LPSTR ) AS LONG PASCAL LIB ".\Pos.dll"


Of course the trick is in the POS.DLL. Being a work in progress, I wouldn't like to make it public yet. But I'll be happy to send a copy to anybody interested. From the above code you can see how easy is to use it. It has taken Otto all of ten minutes to include it in his software :-)

Rafael
User avatar
Rafael Clemente
 
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Postby Otto » Thu Dec 13, 2007 2:59 pm

Regards,
Otto
Image
User avatar
Otto
 
Posts: 6337
Joined: Fri Oct 07, 2005 7:07 pm

Postby Biel EA6DD » Thu Dec 13, 2007 3:27 pm

Please Rafael can you send me a copy, thanks.

bmaimo@piema.info
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 51 guests