FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Plotting locations on Google Maps
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Plotting locations on Google Maps
Posted: Fri Mar 17, 2017 02:16 PM
In your previous sample, You are using the address to put the markers.

Code (fw): Select all Collapse
   AAdd( aDatas, VerMapa2( "28850", "Calle Manuel Sandoval", "1", "Torrejon de Ardoz", "Madrid", "Spain" ) )


I need to do this using Latitude e longitude. I have this code that is working:
Code (fw): Select all Collapse
STATIC FUNCTION ShowGoogleMap(aData)
LOCAL cHtmlContent1,cHtmlContent2, oOle, i,cMapFile
LOCAL cAppendStr:="var locations = ["+CRLF

   cMapFile:= RetArqTmp("htm")+".htm"
   FOR i:=1 to Len(aData)
       cAppendStr+=Space(4)+"['" +aData[i][1] +"',"+Ltrim(Str(aData[i][2]))+","+ Ltrim(Str(aData[i][3]))+ If( i < Len(aData), "],", "]") +CRLF
   NEXT
   cAppendStr+="];"+CRLF


   TEXT INTO cHtmlContent1

       <html>
       <head>

         <title>Google Maps Multiple Markers</title>
         <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
       </head>
       <body>
         <div id="map" style="height: 100%; width: 100%;">
       </div>
       <script type="text/javascript">

   ENDTEXT


   TEXT INTO cHtmlContent2

        var map = new google.maps.Map(document.getElementById('map'), {
        zoom: 0,
         mapTypeId: google.maps.MapTypeId.ROADMAP
         });
        var bounds = new google.maps.LatLngBounds();
        var infowindow = new google.maps.InfoWindow();

        var marker, i;

       for (i = 0; i < locations.length; i++) {
            var position = new google.maps.LatLng(locations[i][1], locations[i][2]);
               bounds.extend(position);
               marker = new google.maps.Marker({
               position: new google.maps.LatLng(locations[i][1], locations[i][2]),
               title: locations[i][0],
               map: map
         });

         google.maps.event.addListener(marker, 'click', (function(marker, i) {
         return function() {
         infowindow.setContent(locations[i][0]);
         infowindow.open(map, marker);
         }
         })(marker, i));

         // Automatically center the map fitting all markers on the screen
         map.fitBounds(bounds);

       }
     </script>
     </body>
     </html>

   ENDTEXT


However, I only can see the titles of the markers if I click over them.
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Plotting locations on Google Maps
Posted: Fri Mar 17, 2017 02:44 PM
Please look function in my sample

viewtopic.php?f=3&t=33729&start=15#p199586

and uncomment line


// XBrowse(


My function VerMapa2, return lat and long and other data
Use only position 2 and 3 of array aData
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Plotting locations on Google Maps
Posted: Fri Mar 17, 2017 02:53 PM
I think I have not understood him well yet

If you have lat and long, Pass the array with that data to the function


ViewLeafLet( aDatas )
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Plotting locations on Google Maps
Posted: Fri Mar 17, 2017 06:19 PM

Cnavarro,

Thank you it's working now ;)
Why the map is not growing when we maximize the window? Is it possible?

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Plotting locations on Google Maps
Posted: Fri Mar 17, 2017 07:47 PM

Try with TActiveX, have a data ::oWnd

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Plotting locations on Google Maps
Posted: Fri Mar 17, 2017 08:31 PM
I tried this:

Code (fw): Select all Collapse
    
  DEFINE WINDOW oWndEdt 
 
      oAct:=TActiveX():New(oWndEdt,"Shell.Explorer.2")
       oWndEdt:oClient = oAct 

   ACTIVATE WINDOW oWndEdt MAXIMIZED;  ;
       VALID (lCancela:=.t.)

       oAct:Navigate(cMapFile)


However, when I changed to this, only the first mark is shown, and I have severals marks.
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Plotting locations on Google Maps
Posted: Fri Mar 17, 2017 08:44 PM

Try in clausule ON INIT of oWndEdt -> oAct:Navigate(cMapFile)

Also try in clausule ON PAINT

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Plotting locations on Google Maps
Posted: Fri Mar 17, 2017 09:09 PM
With ActiveX I have this screen:


With exactly the same code, but changing for show with createobject, I have this screen:

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Plotting locations on Google Maps
Posted: Fri Mar 17, 2017 09:20 PM
Try

Code (fw): Select all Collapse
   MEMOWRIT( cMapFile, cHtmlContent1 + cInitMap + cHtmlContent2 + cAppendStr + cHtmlContent3 )
   CreaWin( cMapFile )

   /*
   oOle := CreateObject( "InternetExplorer.Application" )
   //oOle:bOnEvent  := { | n1, n2, n3 | LeafLetEvent( n1, n2, n3 ) }
   oOle:Width     := 750
   oOle:Height    := 650
   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()
   */
Return nil

//----------------------------------------------------------------------------//

Function CreaWin( cMapFile )

   local oWnd
   local oAct
   local lCancela := .F.
   DEFINE WINDOW oWnd
 
   ACTIVATE WINDOW oWnd MAXIMIZED  ;
       VALID ( lCancela:=.t., .T. ) ;
       ON INIT ( ;
          oAct    := TActiveX():New( oWnd, "Shell.Explorer.2"), ;
          oWnd:oClient := oAct, ;
          oAct:Navigate( cMapFile ), SysRefresh() )

Return nil

//----------------------------------------------------------------------------//


But you have to modify the function



<body>
<div id="mapid" style="width: 700px; height: 560px;"></div>
<script>

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Plotting locations on Google Maps
Posted: Sat Mar 18, 2017 03:50 AM
Instead of
cnavarro wrote:

<body>
<div id="mapid" style="width: 700px; height: 560px;"></div>
<script>



It would be better to use
<div id="map" style="height: 100%; width: 100%;">
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Plotting locations on Google Maps
Posted: Mon Mar 20, 2017 11:45 AM
anserkk wrote:Instead of
cnavarro wrote:

<body>
<div id="mapid" style="width: 700px; height: 560px;"></div>
<script>



It would be better to use
<div id="map" style="height: 100%; width: 100%;">


When I change to this, the map is not shown :-)
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Plotting locations on Google Maps
Posted: Mon Mar 20, 2017 11:48 AM
cnavarro wrote:Try

Code (fw): Select all Collapse
   MEMOWRIT( cMapFile, cHtmlContent1 + cInitMap + cHtmlContent2 + cAppendStr + cHtmlContent3 )
   CreaWin( cMapFile )

   /*
   oOle := CreateObject( "InternetExplorer.Application" )
   //oOle:bOnEvent  := { | n1, n2, n3 | LeafLetEvent( n1, n2, n3 ) }
   oOle:Width     := 750
   oOle:Height    := 650
   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()
   */
Return nil

//----------------------------------------------------------------------------//

Function CreaWin( cMapFile )

   local oWnd
   local oAct
   local lCancela := .F.
   DEFINE WINDOW oWnd
 
   ACTIVATE WINDOW oWnd MAXIMIZED  ;
       VALID ( lCancela:=.t., .T. ) ;
       ON INIT ( ;
          oAct    := TActiveX():New( oWnd, "Shell.Explorer.2"), ;
          oWnd:oClient := oAct, ;
          oAct:Navigate( cMapFile ), SysRefresh() )

Return nil

//----------------------------------------------------------------------------//


But you have to modify the function



<body>
<div id="mapid" style="width: 700px; height: 560px;"></div>
<script>



IF I'm using with ActiveX, only one mark is shown and I'm inserting two.
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Plotting locations on Google Maps
Posted: Wed Mar 22, 2017 12:05 AM

Using your leaflet sample, what command line is adding the shading of the space between the markers ? I only want to display the markers, and not connect them.

In my case, the connecting lines are all over the place, so it looks like a star, rather than just outlining the perimeter of the markers.

Tim

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Plotting locations on Google Maps
Posted: Wed Mar 22, 2017 11:43 AM
Timstone,

To remove the polygon, change this:

Code (fw): Select all Collapse
cAppendStr += "]).addTo(mymap).bindPopup('I am a polygon.');" + CRLF + CRLF


For this:
Code (fw): Select all Collapse
cAppendStr += "]);" + CRLF + CRLF
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: Plotting locations on Google Maps
Posted: Tue Nov 13, 2018 11:22 PM

Hi guys,
I have been used the code include in this topic for several months, but since yesterday don't work anymore.
I think they made any change on Google Maps. Do you know what was changed ?

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil