GOEARTH & GMAPD problem

GOEARTH & GMAPD problem

Postby Romeo » Tue Nov 15, 2016 5:16 pm

Hi,

I'am tring the GOEARTH.PRG and GMAPD.PRG in sample dir, but i got the same problem: Error in script page....

And didn't get any MAP !

Any help ?

FWH 16.02
HARBOUR 3.2.0dev

Tks
Romeo
 
Posts: 340
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Re: GOEARTH & GMAPD problem

Postby Antonio Linares » Wed Nov 16, 2016 8:32 am

Google Maps API has changed from v2 to v3. Thats why the example is not working fine.

Here you have an example of the right code to use:
https://developers.google.com/maps/documentation/javascript/

Code: Select all  Expand view
<!DOCTYPE html>
<html>
  <head>
    <!-- This stylesheet contains specific styles for displaying the map
         on this page. Replace it with your own styles as described in the
         documentation:
         https://developers.google.com/maps/documentation/javascript/tutorial -->
    <link rel="stylesheet" href="/maps/documentation/javascript/demos/demos.css">
  </head>
  <body>
    <div id="map"></div>
    <script>
      function initMap() {
        // Create a map object and specify the DOM element for display.
        var map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: -34.397, lng: 150.644},
          scrollwheel: false,
          zoom: 8
        });
      }

    </script>
    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
    async defer></script>
  </body>
</html>


goearth.prg basically generates such HTML file and loads it from a web browse ActiveX from FWH
regards, saludos

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

Re: GOEARTH & GMAPD problem

Postby Romeo » Wed Nov 16, 2016 4:51 pm

Many thanks.....but (!)

I need a working sample of GMAP.HTML to be used with GMAPD.PRG of sample dir

This example is good for me to init a program to show more customers on google map (by address)!

(it could be wanderful to have an HTML example to show 2 point by address, not coordinates)

Tks Any Ant
Romeo
 
Posts: 340
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Re: GOEARTH & GMAPD problem

Postby anserkk » Thu Nov 17, 2016 7:34 am

Try this sample.

Please note that you will need to register with Google and obtain the API Key to use this in your application.

This test sample works without the API key, I am not sure about the time frame that Google allows to use Google Maps without an API Key.

Code: Select all  Expand view
#Include "FiveWin.ch"

//-----------------------------
Function Main()
    TestGoogleMap("Eiffel Tower","Champ de Mars", "5 Avenue Anatole France", "75007 Paris", "France")
Return NIL

//-----------------------------------------------------------------------/
Function TestGoogleMap(cName,cAddress,cCity,cState,cCountry)
   Local oHttp, cURL, lNetError, cBuffer, cLatLongDtls, cLatitude, cLongitude
   Local cMapFile, cHtmlContent, oOle

   cName:=STRTRAN(ALLTRIM(cName)," ","+")
   cName:=STRTRAN(ALLTRIM(cName),"&"," E ")
   cAddress:=STRTRAN(ALLTRIM(cAddress),",","")
   cAddress:=STRTRAN(ALLTRIM(cAddress)," ","+")
   cCity:=STRTRAN(ALLTRIM(cCity)," ","+")
   cCountry:=STRTRAN(ALLTRIM(cCountry)," ","+")
   
   IF IsInternet()
      oHttp:=CreateObject("Microsoft.XMLHTTP")
      cURL:="http://maps.google.com/maps/api/geocode/json?address="+cAddress+"+"+cCity+"+-+"+cState+"+"+cCountry+"&sensor=false"
      oHttp:Open("GET",cURL,.F.)
      lNetError:=.F.
      TRY
         oHttp:Send()
      CATCH oError
         lNetError:=.T.
      END TRY

      IF !lNetError
         cBuffer := oHttp:ResponseBody
      ELSE
        MsgInfo("Search Error. Could not find the details","Google Maps")
        Return
      ENDIF

      cLatLongDtls:=AT("location",cBuffer)
      IF cLatLongDtls == ""
         MsgInfo("Search Error. Could not find the details","Google Maps")
      ELSE
         cBuffer:=RIGHT( cBuffer,LEN(cBuffer)-cLatLongDtls )
         cLatitude:=SUBSTR(cBuffer,AT("lat",cBuffer)+6,14);cLatitude:=ALLTRIM( LEFT(cLatitude,AT(",",cLatitude)-1) )
         cLongitude:=ALLTRIM(SUBSTR(cBuffer,AT("lng",cBuffer)+6,14))
         cMapFile := "C:\GMaps.htm"
         /* Method 1 */
         cHtmlContent:= ;      
                        '<!DOCTYPE html>' + ;
                        '<html>' + ;
                        '  <head>' + ;
                        '    <style>' + ;
                        '       #map {' + ;
                        '        height: 400px;' + ;
                        '        width: 100%;' + ;
                        '       }' + ;
                        '    </style>' + ;
                        '  </head>' + ;
                        '  <body>' + ;
                        '    <h3>My Google Maps Demo</h3>' + ;
                        '    <div id="map"></div>' + ;
                        '    <script>' + ;
                        '      function initMap() {' + ;
                        '        var uluru = {lat: '+cLatitude+', lng: '+cLongitude+'};' + ;
                        '        var map = new google.maps.Map(document.getElementById("map"), {' + ;
                        '          zoom: 14,' + ;
                        '          center: uluru' + ;
                        '        });' + ;
                        '        var marker = new google.maps.Marker({' + ;
                        '          position: uluru,' + ;
                        '          map: map' + ;
                        '        });' + ;
                        '      }' + ;
                        '    </script>' + ;
                        '    <script async defer' + ;
                        '    src="https://maps.googleapis.com/maps/api/js?key=&callback=initMap">' + ;
                        '    </script>' + ;
                        '  </body>' + ;
                        '</html>         '
         
         
         
         
 /*   Method 2. This is another option. If you plan to use then comment the Previous HTML Content    
         cHtmlContent:='<iframe width="625" height="450" frameborder="0" scrolling="no" marginheight="0"'+;
                      ' marginwidth="0" src="http://maps.google.com/?ie=UTF8&amp;hq=&amp;'+;
                      'hnear='+;
                      '&amp;ll='+cLatitude+','+cLongitude+'&amp;spn='+cLatitude+','+cLongitude+'&amp;z=17&amp;output=embed">'
*/
                     
         MEMOWRIT( cMapFile, cHtmlContent )

         oOle:=CreateObject("InternetExplorer.Application")
         oOle:width:=675
         oOle:height:=520
         oOle:Visible:=.t. // Displays the Browser
         oOle:ToolBar:=.f. // Disables the toolbar
         oOle:StatusBar:=.f. // Disables status bar
         oOle:MenuBar:=.f. // Disables the menu bar
         oOle:Navigate(cMapFile) // Open the Webpage
         SysRefresh()
      ENDIF
     
   ENDIF
   
Return
 

Regards

Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: GOEARTH & GMAPD problem

Postby Antonio Linares » Thu Nov 17, 2016 8:51 am

Anser,

many thanks :-)
regards, saludos

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

Re: GOEARTH & GMAPD problem

Postby Romeo » Thu Nov 17, 2016 4:46 pm

many thanks
Romeo
 
Posts: 340
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 106 guests