call a xojo method from javascript

I’m exploring how to develop webs App working with mapLocation… I’m drawing different circles in specific locations and I would like to call a method clicking a button created by Javascript… is that posible?

    
while NOT ad.EOF
     s = s + "var centerAd = new google.maps.LatLng(parseFloat("+ad.Field("ZLATITUD").stringValue+"),parseFloat("+ad.Field("ZLONGITUD").stringValue+"));"+EndOfLine
      s = s + "var populationOptions = {"+EndOfLine
      s = s + "strokeColor: '"+colorAd+"',"+EndOfLine
      s = s + "strokeOpacity: 0.8,"+EndOfLine
      s = s + "strokeWeight: 3,"+EndOfLine
      s = s + "map: map,"+EndOfLine
      s = s + "center: centerAd,"+EndOfLine
      s = s + "clickable:true,"+EndOfLine
      s = s + "radius: 800"+EndOfLine
      s = s + "};"+EndOfLine

      // Add the circle for this city to the map.
      s = s + "cityCircle["+ str(i) +"] = new google.maps.Circle(populationOptions);"+EndOfLine
      s = s + "infowindow["+ str(i) +"] = new google.maps.InfoWindow({"+EndOfLine
      
      //***************** HERE IS WHERE I CREATE THE BUTTON********************
      s = s + "content:'<b>" + ad.Field("ZDESIG").stringValue + "</b><br>"+ replaceall(ad.Field("ZNOMBRE").stringValue,"'"," ") +"<br>"+ ad.Field("ZUSO").stringValue+"<br><br><button onClick=(HERE I WANT TO CALL A METHOD); style=width:155px;>Agregar al Plan</button>' });"+EndOfLine
      
      s = s + "google.maps.event.addListener(cityCircle[" + str(i) + "], 'click', function(ev) {"+EndOfLine
      s = s + "infowindow["+ str(i) +"].setPosition(cityCircle[" + str(i) + "].getCenter());"+EndOfLine
      s = s + "infowindow["+ str(i) +"].open(map);});"+EndOfLine

     i = i+1

ad.MoveNext
wend

ExecuteJavaScript(s)

Look up Xojo.triggerServerEvent in WebControlSDK.pdf, pages 8 and 9. That command within a JavaScript program will trigger the ExecuteEvent of the WebControlWrapper where you can call any Xojo method you like.

Thanks!!!

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.