hi,

I show a map using html with WebBrowser component.
I created a javascript in the html code with the intent to load the values 
of the latitude and longitude is given every time a click on the map.

*HTML code:*
*Javascript Function*
function Taxi(nombre, latitud, longitud) { 
    this.nombre = nombre; 
    this.latitud = latitud; 
    this.longitud = longitud; 
 }
*Code to call the function in HTML:*
 // Adiciona un listener (escucha) para evento click 
 google.maps.event.addListener(poligono, 'click', showPoligono); }

function showPoligono(event) { 
    var desc = this.desc; 
     datos = new Taxi(desc, event.latLng.lat(),event.latLng.lng()); 
 }
My intention is to load the global variable "data" every time the "click" 
event runs on the map

*Codename one Code:*
// Show Map
            webBrowser = new WebBrowser() {
                @Override
                public void onLoad(String url) {
                    Component c = getInternal();
                    if (c instanceof BrowserComponent) {
                        BrowserComponent b = (BrowserComponent) c;
                        // EnvĂ­a parametros al html
                        String mes = new String();
                        b.execute("mapa('" + mes + "')");
                    }
                }
            };
            webBrowser.setURL("jar:///mapa.html");

// Listen position
            final BrowserComponent c = (BrowserComponent) 
webBrowser.getInternal();
            final JavascriptContext ctx = new JavascriptContext(c);
            c.addWebEventListener("onLoad", new ActionListener() {
                public void actionPerformed(ActionEvent evt) {

                    JSObject pageContent = (JSObject) ctx.get("datos");

                    Dialog.show("Content", pageContent.getString("nombre") 
+ " " + pageContent.getString("latitud")+ " " + 
pageContent.getString("longitud"), "OK", "Cancel");

                }
            });

As I make this work?

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/f3327fd1-22bb-4e12-b646-9ba27eedd154%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to