Draw a MAP

Draw a MAP

Postby Silvio.Falconi » Mon Jul 17, 2017 10:54 am

How creat a map to draw a tour of a Bus sample :

Image

and have a table with all stazionary with distance
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: Draw a MAP

Postby Otto » Wed Jul 19, 2017 6:27 am

Hello Silvio,
how are you?
Have you tried:
oWnd:line(...)
METHOD Line( nTop, nLeft, nBottom, nRight )
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6347
Joined: Fri Oct 07, 2005 7:07 pm

Re: Draw a MAP

Postby Maurizio » Wed Jul 19, 2017 6:52 am

Ciao Silvio,
perchè non usi googlemaps ?

Maurizio
User avatar
Maurizio
 
Posts: 825
Joined: Mon Oct 10, 2005 1:29 pm

Re: Draw a MAP

Postby Silvio.Falconi » Wed Jul 19, 2017 7:26 am

ci ho pensato ma se il cliente non ha internet che faccio ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: Draw a MAP

Postby Silvio.Falconi » Thu Jul 27, 2017 4:04 pm

I tried with Map google but I have some problems with this test sample of Cristobal Navarro
Code: Select all  Expand view  RUN
#include "FiveWin.ch"

Static cUrl     := ""

Function Main()

   Local aDatas := {}
   SET 3DLOOK OFF





    AAdd( aDatas, VerMapa2( "64100", "Piazza San Francesco", "1", "Teramo", "Abruzzo", "Italy" ) )
    AAdd( aDatas, VerMapa2( "64100", "Strada statale 80", "1", "Piano D'accio", "Abruzzo", "Italy" ) )
    AAdd( aDatas, VerMapa2( "64100", "Strada statale 80", "1", "San Nicolò A Tordino", "Abruzzo", "Italy" ) )
    AAdd( aDatas, VerMapa2( "64020", "Strada statale 80", "1", "Bellante Stazione", "Abruzzo", "Italy" ) )
    AAdd( aDatas, VerMapa2( "64023", "Strada statale 80", "1", "Selva Piana", "Abruzzo", "Italy" ) )
    AAdd( aDatas, VerMapa2( "64023", "Strada statale 80", "1", "Mosciano Stazione", "Abruzzo", "Italy" ) )
    AAdd( aDatas, VerMapa2( "64021", "Strada statale 80", "1", "Colleranesco", "Abruzzo", "Italy" ) )

   ViewLeafLet( aDatas )

Return nil

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

Function VerMapa2( cPostal_Code, cStreet, cNumber, cLocality, cState, cNation )

   Local cWeb  := "http://maps.google.it/maps/place/"
   local cMap
   local cRet  := ""
   local oOle
   local nPos1
   local nPos2
   local aCoor := { 0, 0, 0 }
   cPostal_Code := StrTran( AllTrim( cPostal_Code ), ' ', '+' )
   cStreet      := StrTran( AllTrim( cStreet ), ' ', '+' )
   cNumber      := StrTran( AllTrim( cNumber ), ' ', '+' )
   cLocality    := StrTran( AllTrim( cLocality ), ' ', '+' )
   cState       := StrTran( AllTrim( cState ), ' ', '+' )
   cNation      := StrTran( AllTrim( cNation ), ' ', '+' )
   cMap     :=  AllTrim( cPostal_Code ) + "+" + AllTrim( cStreet ) + "+" + ;
                AllTrim( cNumber ) + "+" + AllTrim( cLocality ) + "+" + ;
                AllTrim( cState ) + "+" + AllTrim( cNation )
   oOle  := CreateObject("Winhttp.WinHttpRequest.5.1")
   oOle:Open( "GET", cWeb + AllTrim( cMap ), .F. )
   oOle:Send()
   cURL := oOle:ResponseText

   nPos1  := At( "cacheResponse([[[", Left( cURL, 2048 ) )
   if !Empty( nPos1 )
      cRet   := Substr( Left( cURL, 1024 ), nPos1 + 17, 2048 - nPos1 )
      nPos2  := At( "]", cRet )
      if !Empty( nPos2 )
         cRet   := Left( cRet, nPos2 - 1 )
         aCoor  := hb_ATokens( cRet, "," )
      endif
   endif
   //XBrowse( aCoor )

Return aCoor

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

Function ViewLeafLet(aData)

   local cMapFile   := "C:\work\Errori\mappa_google\GMaps.htm"
   local cHtmlContent1
   local cHtmlContent2
   local cHtmlContent3
   local cInitMap   := "   var mymap = L.map('mapid').setView( [ "
   local cAppendStr := "   L.polygon([" + CRLF
   local oOle
   local i

   TEXT INTO cHtmlContent1

   <!DOCTYPE html>
   <html>
   <head>
       <title>Quick Start - Leaflet</title>

       <meta charset="utf-8" />
       <meta name="viewport" content="width=device-width, initial-scale=1.0">

       <link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />

       <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
       <script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script>
   </head>
   <body>
      <div id="mapid" style="width: 900px; height: 560px;"></div>
      <script>
   ENDTEXT

   cInitMap  += aData[ 1 ][ 3 ] + ", " + aData[ 1 ][ 2 ] + " ], 13);" + CRLF

   TEXT INTO cHtmlContent2
    L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
        maxZoom: 18,
        attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
            '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
            'Imagery © <a href="http://mapbox.com">Mapbox</a>',
        id: 'mapbox.streets'
    }).addTo(mymap);

   ENDTEXT

  For i := 1 to Len( aData )
      cAppendStr += Space( 4 ) + "[ " + aData[ i ][ 3 ] + ", " + ;
                    Ltrim( aData[ i ][ 2 ] )
      if i < Len( aData )
         cAppendStr += "]," + CRLF
      else
         cAppendStr += "]" + CRLF
      endif
   Next
   cAppendStr += "]).addTo(mymap).bindPopup('I am a polygon.');" + CRLF + CRLF

   For i := 1 to Len( aData )
      cAppendStr += "L.marker( "
      cAppendStr += "[ " + aData[ i ][ 3 ] + ", " + ;
                    Ltrim( aData[ i ][ 2 ] ) + " ] )."
      cAppendStr += "addTo(mymap).bindPopup('<b>Marker" + Str( i ) + " !</b><br />I am a popup.').openPopup();" + CRLF + CRLF
   Next

/*   For i := 1 to Len( aData )
      cAppendStr += "L.marker( "
      cAppendStr += "[ " + aData[ i ][ 3 ] + ", " + ;
                    Ltrim( aData[ i ][ 2 ] ) + " ] ).addTo(mymap).bindTooltip('my tooltip text').openTooltip();" + CRLF + CRLF
   Next
    */





   TEXT INTO cHtmlContent3
    var popup = L.popup();

    function onMapClick(e) {
        popup
            .setLatLng(e.latlng)
            .setContent("Position is: " + e.latlng.toString())
            .openOn(mymap);
    }

   mymap.on('click', onMapClick);

   </script>

   </body>
   </html>

   ENDTEXT

   MEMOWRIT( cMapFile, cHtmlContent1 + cInitMap + cHtmlContent2 + cAppendStr + cHtmlContent3 )

   oOle := CreateObject( "InternetExplorer.Application" )
   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

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

 

1. the test load iexplorer and not chrome window: good can be if the user can select with browse to use


2. sometime run sometimes not found the website ( making error) I not understood why

3. if I use
Local cWeb := "http://maps.google.it/maps/place/"

the test create a polygon from Rome

Image


if I use
Local cWeb := "http://maps.google.es/maps/place/"

the test create a polygon from Madrid

Image


I wish show this (it is possible ) and on a dialog on top with the possibility to scroll the map on horizontal

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: karinha and 39 guests