Page 1 of 1
GOEARTH & GMAPD problem
Posted: Tue Nov 15, 2016 5:16 pm
by Romeo
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
Re: GOEARTH & GMAPD problem
Posted: Wed Nov 16, 2016 8:32 am
by Antonio Linares
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/docu ... avascript/
Code: Select all
<!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
Re: GOEARTH & GMAPD problem
Posted: Wed Nov 16, 2016 4:51 pm
by Romeo
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
Re: GOEARTH & GMAPD problem
Posted: Thu Nov 17, 2016 7:34 am
by anserkk
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
#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&hq=&'+;
'hnear='+;
'&ll='+cLatitude+','+cLongitude+'&spn='+cLatitude+','+cLongitude+'&z=17&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
Re: GOEARTH & GMAPD problem
Posted: Thu Nov 17, 2016 8:51 am
by Antonio Linares
Anser,
many thanks
Re: GOEARTH & GMAPD problem
Posted: Thu Nov 17, 2016 4:46 pm
by Romeo
many thanks