How creat a map to draw a tour of a Bus sample :
and have a table with all stazionary with distance
#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 © <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
//----------------------------------------------------------------------------//
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 48 guests