Hi @infratec.
Thank you for helping me.
HTML named map.html
Code: Select all
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<title>Mappa Leaflet</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
crossorigin=""></script>
<style>
html, body {
height: 70%;
width: 70%;
margin: 10;
padding: 10;
}
#map {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map = null;
//MAPPA
document.addEventListener('DOMContentLoaded', function() {
map = L.map('map').setView([10, 30], 3);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
});
function dammivalore(valo) {
alert("ciao"); //-> FUNZIONA
return (valo * 2) + "A";
}
</script>
</body>
</html>
PUREBASIC
File a1.pb
Code: Select all
XIncludeFile "FormMain.pbf" ; include il file generato dal Designer
Declare LoadMap()
OpenFormMain() ;Apre la finestra principale
;LoadMap() ;Carica Leaflet
;In attesa di eventi dalla finestra
Repeat
Until FormMain_Events(WaitWindowEvent()) = #False ;PB_Event_CloseWindow
Procedure DammiValoreCallback(JsonParameters$)
;NO WORK !!!!!!
Debug "Step 3"
Dim Parameters(0)
ParseJSON(0, JsonParameters$)
ExtractJSONArray(JSONValue(0), Parameters())
Debug "Parametro ricevuto: " + Str(Parameters(0))
ProcedureReturn UTF8(Str(Parameters(0)))
EndProcedure
; Procedura che chiama la funzione JavaScript
Procedure pio(EventType)
Debug "Step 1" ;OK WORK
BindWebViewCallback(WVMap, "dammivalore(5)", @DammiValoreCallback())
Debug "Step 2" ;OK WORK
EndProcedure
File FormMain.pbf
Code: Select all
;
; This code is automatically generated by the Form Designer.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures need to be put in another source file.
;
Global FormMain
Global Cnt_Up, MenuSx, Cnt_Giu, Button_1, WVMap
Declare ResizeGadgetsFormMain()
Declare pio(EventType)
Procedure OpenFormMain(x = 0, y = 0, width = 1180, height = 640)
FormMain = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
Cnt_Up = ContainerGadget(#PB_Any, 0, 0, 1180, 50)
SetGadgetColor(Cnt_Up, #PB_Gadget_BackColor,RGB(128,255,255))
MenuSx = ButtonGadget(#PB_Any, 10, 10, 100, 25, "<<")
CloseGadgetList()
Cnt_Giu = ContainerGadget(#PB_Any, 0, 50, 140, 580)
SetGadgetColor(Cnt_Giu, #PB_Gadget_BackColor,RGB(255,255,0))
Button_1 = ButtonGadget(#PB_Any, 20, 40, 100, 25, "")
CloseGadgetList()
WVMap = WebViewGadget(#PB_Any, 140, 50, 1040, 590)
EndProcedure
Procedure ResizeGadgetsFormMain()
Protected FormWindowWidth, FormWindowHeight
FormWindowWidth = WindowWidth(FormMain)
FormWindowHeight = WindowHeight(FormMain)
ResizeGadget(Cnt_Up, 0, 0, FormWindowWidth - 0, FormWindowHeight - 590)
ResizeGadget(WVMap, 140, 50, FormWindowWidth - 140, FormWindowHeight - 50)
EndProcedure
Procedure FormMain_Events(event)
Select event
Case #PB_Event_SizeWindow
ResizeGadgetsFormMain()
Case #PB_Event_CloseWindow
ProcedureReturn #False
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case MenuSx
pio(EventType())
EndSelect
EndSelect
ProcedureReturn #True
EndProcedure