rob:
webView:request( “map.html”, system.DocumentsDirectory ) is trying to load a file called map.html, but at the top you mention “marker.html”.
Could this be the source of your error?
Rob
mmh… no (i think)
This is the full source:
googlemap.lua (loaded form mappe.lua)
do local M={} -- GOOGLE MAP da ottimizzare e trasformare in modulo local path = system.pathForFile( "map.html", system.DocumentsDirectory ) function M.renderMap(sites) local sitesString = table.concat(sites) --print(sitesString) local centerMaps={} centerMaps[1]=44.647128 centerMaps[2]=10.925226899999984 local markersRender={} for i=0,4 do markersRender[i]=[[ var sites = markers[]]..i..[[]; var siteLatLng = new google.maps.LatLng(sites[1], sites[2]); var marker = new google.maps.Marker({ position: siteLatLng, map: map, title: sites[0], url\_page: sites[5], zIndex: sites[3], html: sites[4] }); marker.html = '\<form action=\"corona:'+sites[6]+'\"\>\<input type=\"submit\"/ value=\"'+sites[0]+'\" \>\</form\>'; google.maps.event.addListener(marker, "click", function () { //window.open("OPEN:"+this.title); //document.location.href = "" //infowindow.setContent(this.html); //infowindow.open(map, this); infoBubble.setContent(this.html); infoBubble.open(map, this); }); ]] end local markerString = table.concat(markersRender) --print(markerString) --HTML & JAVASCRIPT CODE local mapString=[[\<!DOCTYPE html\> \<html\> \<head\> \<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /\> \<style type="text/css"\> html { height: 100% } body { height: 100%; margin: 0; padding: 0 } #map\_canvas { height: 100% } \</style\> \<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?&sensor=true&language="\> \</script\> \<script type="text/javascript" src="https://raw.githubusercontent.com/googlemaps/js-info-bubble/gh-pages/src/infobubble.js"\> \</script\> \<script type="text/javascript"\> function initialize() { var sites = [ ]]..sitesString..[[ ]; var myOptions = { center: new google.maps.LatLng(]]..centerMaps[1]..[[,]]..centerMaps[2]..[[), zoom: 12, disableDoubleClickZoom: true, scrollwheel: true, draggable: true, disableDefaultUI: true, zoomControl: true, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map\_canvas"), myOptions); setMarkers(map, sites); var prev\_infowindow = true; //Custom Vars for controlling certain aspects var allowStyling = false; var bouncingPins = false; function setMarkers(map, markers) { infoBubble = new InfoBubble({ maxWidth: 300 }); infoBubble = new InfoBubble({ map: map, content: '', shadowStyle: 1, padding: 0, backgroundColor: 'rgb(57,57,57)', borderRadius: 4, arrowSize: 10, borderWidth: 1, borderColor: '#2c2c2c', disableAutoPan: true, hideCloseButton: true, arrowPosition: 30, backgroundClassName: 'phoney', arrowStyle: 2 }); ]]..markerString..[[ } } \</script\> \</head\> \<body onload="initialize()"\> \<div id="map\_canvas" style="width:100%; height:100%"\>\</div\> \<iframe id="l" width="1" height="1" style="visibility:hidden"\>\</iframe\> \</body\> \</html\>]] --HTML FILE CREATION local file = io.open( path, "w" ) file:write( mapString ) io.close( file ) end return M end
and mappe.lua
do local composer = require("composer") local scene = composer.newScene() local widget = require("widget") local http = require("socket.http") local url = require("socket.url") local json = require "json" local navbarScript = require("navbar") local response = http.request("https://www.quiboapp.com/json/map\_locals.php") local \_page=display.newGroup() local pageName=composer.getVariable("title") print("Loaded... Title: "..pageName) local backgroundView = require("background") local \_page=display.newGroup() \_page:insert(backgroundView.image("background.png")) \_page:insert(navbarScript.renderNavBar("menu")) local googleMaps = require("googlemap") local templateScehda = require("template") local webView local decoded, pos, msg = json.decode( response ) if not decoded then print( "Decode failed at "..tostring(pos)..": "..tostring(msg) ) end -- "scene:create()" function scene:create( event ) local sceneGroup = self.view -- Initialize the scene here. -- Example: add display objects to "sceneGroup", add touch listeners, etc. end -- GOOGLE MAP da ottimizzare e trasformare in modulo local sites={} for m=1,#decoded do sites[m]=[[ [']]..decoded[m].locale\_nome..[[',']]..decoded[m].lat..[[',']]..decoded[m].lng..[[','1',']]..decoded[m].locale\_nome..[[',']]..decoded[m].url\_page..[[',']]..decoded[m].locale\_id..[['], ]] end googleMaps.renderMap(sites) local function webListener( event ) if event.url then print( "You are visiting: " .. event.url ) if 1 == string.find( event.url, "corona:" ) then local url = string.gsub(event.url, "corona:", "") print(url) --composer.setVariable("title","scheda") composer.removeScene("scheda") composer.gotoScene("scheda","slideLeft", 250) --showMarkerInfo( url ) end end if event.type then if event.type~="loaded" and event.type~="other" then --local webView = require("webViewController") --local ww=webView.controller("https://www.quiboapp.com/json/wv\_dove\_mangiato.php?user\_id=2077",160,240,320,480) --\_page:insert(ww) end print( "The event.type is " .. event.type ) -- print the type of request end if event.errorCode then native.showAlert( "Error!", event.errorMessage, { "OK" } ) end end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then sceneGroup:insert(\_page) elseif ( phase == "did" ) then native.setActivityIndicator( false ) webView = native.newWebView( 160, 240, 320, 480 ) webView:addEventListener("urlRequest", webListener) webView:request( "map.html", system.DocumentsDirectory ) \_page:insert(webView) -- Called when the scene is now on screen. -- Insert code here to make the scene come alive. -- Example: start timers, begin animation, play audio, etc. end end -- "scene:hide()" function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then if webView and webView.removeSelf then webView:removeSelf() webView = nil end -- composer.removeScene(pageName) -- Called when the scene is on screen (but is about to go off screen). -- Insert code here to "pause" the scene. -- Example: stop timers, stop animation, stop audio, etc. elseif ( phase == "did" ) then composer.removeScene(pageName) -- Called immediately after scene goes off screen. end end -- "scene:destroy()" function scene:destroy( event ) local sceneGroup = self.view for i=1,self.view.numChildren do local c = self.view[i] c:removeSelf() end package.loaded["background"] = nil package.loaded["navbar"] = nil package.loaded["webViewController"] = nil package.loaded["webView"] = nil -- Called prior to the removal of scene's view ("sceneGroup"). -- Insert code here to clean up the scene. -- Example: remove display objects, save state, etc. end -- ------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene end
thanks in advance for your help.