henrichen / zkgmapsz

Automatically exported from code.google.com/p/zkgmapsz
0 stars 0 forks source link

OnMapClick not fired on Linux #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This example should show a message box when clicking on the map. It does when 
tested in the zk sandbox:

<window title="Google Maps">
    <vbox>
    <gmaps id="mymap" width="500px" height="300px" showSmallCtrl="true">
        <attribute name="onMapClick">
            Messagebox.show("click");
        </attribute>

    </gmaps>
    </vbox>
</window>

I would expect to see a messagebox showing the string "click". It does not 
happen

I am using latest beta: zk-Gmaps-bin-3.0.0-Beta-2012-03-06

Original issue reported on code.google.com by idcglo...@orpi.com on 6 Mar 2012 at 2:09

GoogleCodeExporter commented 9 years ago
Tested with chrome and firefox in Linux

Original comment by idcglo...@orpi.com on 6 Mar 2012 at 2:12

GoogleCodeExporter commented 9 years ago
tested with firefox client in Windows. Server is linux. Doesn't work either.

Original comment by idcglo...@orpi.com on 6 Mar 2012 at 2:27

GoogleCodeExporter commented 9 years ago
I have done some debugging and I found that the service function:
public void service(org.zkoss.zk.au.AuRequest request, boolean everError)

from the Gmaps class doesn't get called when I click on the map. So it is not a 
problem processing the command but the command not arriving to the java code.

Original comment by javier.i...@gmail.com on 8 Mar 2012 at 10:02

GoogleCodeExporter commented 9 years ago
In the javascript function for processing gmaps mouse clicks it looks like you 
only process the click if it happens on a gmarker, polyline or polygon. That 
means you do not support arbitrary map clicks.

The conditional is this:
if (wgt.$instanceof(gmaps.Gmarker) || wgt.$instanceof(gmaps.Gpolyline) || 
wgt.$instanceof(gmaps.Gpolygon))

Can you confirm that only clicks on markers, polylines and polygons is 
supported? or is this really a bug?

This is the function:

    doClick_: function(evt) {
        var wgt = evt.target;

        //calling this to correct the popup submenu not auto closed issue
        zk.Widget.mimicMouseDown_(wgt);

        if (wgt.$instanceof(gmaps.Gmarker) || wgt.$instanceof(gmaps.Gpolyline) || wgt.$instanceof(gmaps.Gpolygon)) {
            var latLng = evt.latLng? evt.latLng : new google.maps.LatLng(0, 0),
                xy = this._mm.projection_.fromLatLngToDivPixel(latLng, this._gmaps.getZoom()),
                pageXY = gmaps.Gmaps.xyToPageXY(this.parent, xy.x, xy.y),
                data = zk.copy(evt.data, {lat:latLng.lat(),lng:latLng.lng(),reference:wgt,x:xy.x,y:xy.y,pageX:pageXY[0],pageY:pageXY[1]}),
                opts = evt.opts;
            this.fireX(new zk.Event(this, 'onMapClick', data, opts, evt.domEvent));
            // do not select self
            if (wgt != this)
                this.fireX(new zk.Event(this, 'onSelect', {items:[wgt],reference:wgt}, opts, evt.domEvent));
            this.$supers(gmaps.Gmaps, 'doClick_', arguments);
        } 
    },

Original comment by javier.i...@gmail.com on 8 Mar 2012 at 10:12

GoogleCodeExporter commented 9 years ago
Hi,

I have replaced in my copy of gmapsz this line in Gmaps.src.js:

if (wgt.$instanceof(gmaps.Gmarker) || wgt.$instanceof(gmaps.Gpolyline) || 
wgt.$instanceof(gmaps.Gpolygon)) {

with this

if (wgt.$instanceof(gmaps.Gmaps) ||  wgt.$instanceof(gmaps.Gmarker) || 
wgt.$instanceof(gmaps.Gpolyline) || wgt.$instanceof(gmaps.Gpolygon)) {

It now fires the onMapClick events anywhere in the map. I need to do some 
testing, but it seems to achieve what I expect. Is this not the right way of 
doing it?

Original comment by idcglo...@orpi.com on 8 Mar 2012 at 3:46

GoogleCodeExporter commented 9 years ago
No, it is not the right way I think.

Because the x/y and pageX/pageY and the target will contain wrong value,
I'll fix it in 3.0.0 today.

Original comment by benbai...@gmail.com on 9 Mar 2012 at 4:51

GoogleCodeExporter commented 9 years ago
Fixed since 2012-03-09.

Original comment by benbai...@gmail.com on 9 Mar 2012 at 7:46