andydoroga1989 / gwt-google-apis

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

InfoWindow.open() Doesn't work with Marker argument #411

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Found in Release:
1.1.0

Detailed description:
When trying to use the InfoWindow I cannot call open() with the Marker as the 
argument.  It works if I extract the Latitude/Longitude pair from the Marker 
but then the Marker no longer owns the window.

The code I've tried: 

final Marker m = new Marker(pos, GetMarkerOpts(icon.type));
m.addMarkerClickHandler(new MarkerClickHandler() {
    public void onClick(MarkerClickEvent event) {
        InfoWindow info = map.getInfoWindow();
        info.open(event.getSender(), new InfoWindowContent(icon.message));
    }
});

I have also tried substituting event.getSender() with the final Marker m object 
but I get the same error either way.
I get the following error in Hosted Mode:

com.google.gwt.core.client.JavaScriptException: (TypeError): Cannot read 
property 'x' of undefined
 stack: TypeError: Cannot read property 'x' of undefined
    at mB.NJ (eval at <anonymous> (http://maps.gstatic.com/intl/en_us/mapfiles/260d/maps2.api/main.js:335:67))
    at mB.Cz (eval at <anonymous> (http://maps.gstatic.com/intl/en_us/mapfiles/260d/maps2.api/main.js:335:67))
    at mB.S (eval at <anonymous> (http://maps.gstatic.com/intl/en_us/mapfiles/260d/maps2.api/main.js:335:67))
    at mj.<anonymous> (http://maps.gstatic.com/intl/en_us/mapfiles/260d/maps2.api/main.js:1198:56)
    at mj.<anonymous> (http://maps.gstatic.com/intl/en_us/mapfiles/260d/maps2.api/main.js:1195:120)
    at http://maps.gstatic.com/intl/en_us/mapfiles/260d/maps2.api/main.js:5:248
    at http://maps.gstatic.com/intl/en_us/mapfiles/260d/maps2.api/main.js:326:58
    at ed.MP (http://maps.gstatic.com/intl/en_us/mapfiles/260d/maps2.api/main.js:322:78)
    at ed.require (http://maps.gstatic.com/intl/en_us/mapfiles/260d/maps2.api/main.js:326:36)
    at Yc (http://maps.gstatic.com/intl/en_us/mapfiles/260d/maps2.api/main.js:335:103)
 type: non_object_property_load
 arguments: x,
 __gwt_ObjectId: 3321

Workaround if you have one:
Use the LatLng function overload instead.  Works but doesn't provide proper 
ownership to the Marker that called it.

Links to the relevant GWT Developer Forum posts:
none found

Original issue reported on code.google.com by obsidianx on 13 Aug 2010 at 10:24

GoogleCodeExporter commented 9 years ago

Original comment by zundel@google.com on 16 Oct 2010 at 10:44

GoogleCodeExporter commented 9 years ago
I got a similar error when I added a sample to the InfoWindowDemo class in 
HelloMaps.
The problem was that the marker needed to be added to the map before calling 
InfoWindow.open(marker, ...)

This patch updates the sample and the javadoc.

http://gwt-code-reviews.appspot.com/1021801/show

Original comment by zundel@google.com on 16 Oct 2010 at 6:37

GoogleCodeExporter commented 9 years ago
I had a similar problem as original poster, and in my case it was because the 
Icon used during Marker creation wasn't initialized correctly. My 
initialisation code was:
    MarkerOptions options = MarkerOptions.newInstance();
    options.setIcon(Icon.newInstance("some_image_url"));
    marker = new Marker(point, options);
something is missing in the icon, resulting in the above mentioned exception. 
The following change fixed the problem:
    MarkerOptions options = MarkerOptions.newInstance();
    Icon icon = Icon.DEFAULT_ICON;
    icon.setImageUrl("some_image_url");
    options.setIcon(icon);
    marker = new Marker(point, options);

Original comment by ivo...@gmail.com on 16 Sep 2011 at 3:07

GoogleCodeExporter commented 9 years ago
Maps API v2 has been deprecated.

Original comment by zundel@google.com on 28 Oct 2011 at 4:12