yugalatea / gwt-google-apis

Automatically exported from code.google.com/p/gwt-google-apis
0 stars 0 forks source link

Invoking map.getInfoWindow().open(Marker, InfoWindowContent) doesn't work #234

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Found in Release:
gwt: 1.5.3
gwt-maps: r1170

Detailed description:

Invoking map.getInfoWindow().open(Marker, InfoWindowContent) doesn't work,
and no exception is shown in the shell. But if I use a
GWT.UncaughtExceptionHandler and run it in Firefox, I get the exception
that is shown in the attached file. Even though I am using -style PRETTY to
compile, I simply have no idea what that means. Here is the code I am
having problem with:

map.addMapRightClickHandler(new MapRightClickHandler() {
    public void onRightClick(MapRightClickEvent event) {
        if (event.getOverlay() instanceof Marker) {
            Marker marker = (Marker) event.getOverlay();

            Label label = new Label("on marker");
            InfoWindowContent content = new InfoWindowContent(label);
            map.getInfoWindow().open(marker, content);
        } else {
            LatLng point = map.convertContainerPixelToLatLng(event.getPoint());

            Label label = new Label("on map");
            InfoWindowContent content = new InfoWindowContent(label);
            map.getInfoWindow().open(point, content);
        }
    }
});

BTW, map.getInfoWindow().open(LatLng, InfoWindowContent) works normally.
The problem is only with the one that accepts a Marker.

Workaround if you have one:

Links to the relevant GWT Developer Forum posts:

Original issue reported on code.google.com by vitor.tc...@gmail.com on 22 Jan 2009 at 7:22

Attachments:

GoogleCodeExporter commented 9 years ago
A workaround is to get the LatLng from the Marker object and then open the 
infowindow 
on the map with that LatLng instead of opening on the Marker.

Original comment by galgwt.reviews@gmail.com on 22 Jan 2009 at 7:32

GoogleCodeExporter commented 9 years ago
I just thought that a few minutes after submitting this issue.

Anyway, digging a little deeper I found that 'b' is undefined in this line of 
code:
function vr(a){var b=a.infoWindowAnchor,c=a.iconAnchor;return new 
D(b.x-c.x,b.y-c.y)}

I have no idea what variable 'a' is, but looking at the Google Maps API 
Reference,
the only type that has a infoWindowAnchor is a GIcon. So, it should be that. 
I'll
take a look in my code where I create these icons, and try to set 
infoWindowAnchor to
see the results.

Original comment by vitor.tc...@gmail.com on 22 Jan 2009 at 7:42

GoogleCodeExporter commented 9 years ago
As I expected, invoking icon.setInfoWindowAnchor(Point.newInstance(10, 0)); 
solves
this problem.

Original comment by vitor.tc...@gmail.com on 22 Jan 2009 at 8:03

GoogleCodeExporter commented 9 years ago
This is a similar issue described in issue 124 related to icons.  

Is your code really using a Marker or are you using an Icon and registering a 
click
handler on it?  If you are creating a Marker from a custom icon, the API fails 
in
different ways depending on whether you've initialized the proper values.  If 
you can
give me more details, we can work out a way to make this more bulletproof.

Also, what version of the Maps API are you using (the output of 
Maps.getVersion()) 
There is some monkey business in Overlay.createPeer() that may need some 
sorting (or
an upgrade to a newer version).

Original comment by galgwt.reviews@gmail.com on 30 Jan 2009 at 4:48

GoogleCodeExporter commented 9 years ago
I am using a Marker with a custom Icon.
Below is the code that was raising this problem:

Icon icon = Icon.newInstance(imgUrl);
icon.setIconSize(Size.newInstance(20, 34));
icon.setIconAnchor(Point.newInstance(9, 34));
icon.setShadowURL(UrlResolver.shadowIcon());
icon.setMaxHeight(13);

MarkerOptions opts = MarkerOptions.newInstance(icon);
opts.setDraggable(draggable);
opts.setBouncy(true);

Marker marker = new Marker(point, opts);

Now, it started to work fine when added this:
icon.setInfoWindowAnchor(Point.newInstance(10, 0));

The problem is that without using GWT.UncaughtExceptionHandler in FF3, nothing
happens, and no message is shown in the HostedBrowser. I believe that a custom 
icon
should come with the default values of the google maps icon. But that is not a
problem of gwt-maps, it is from Google Maps API.

The version I am using of the Maps API is 140g.

Original comment by vitor.tc...@gmail.com on 30 Jan 2009 at 5:05

GoogleCodeExporter commented 9 years ago
the maps v2 api is now deprecated.

Original comment by zundel@google.com on 28 May 2010 at 6:19

GoogleCodeExporter commented 9 years ago
Workaround:

Icon icon = Icon.newInstance(Icon.DEFAULT_ICON);
icon.setImageURL("some-icon-url");

this sets it up properly

Original comment by demisone@gmail.com on 25 Jun 2010 at 12:33