I found that this problem occurs when I have two entry separate points
with map component in each of them. If I use only one entry point with
two component - everything works fine. But there is difficult to use
one common entry point in my project.
The code example below:
public class Test implements EntryPoint {
MapWidget map;
Geocoder geocoder = new Geocoder();
public void onModuleLoad() {
map = new MapWidget();
geocoder.getLatLng("Russia Saint-Petersburg", new
LatLngCallback() {
@Override
public void onSuccess(LatLng point) {
initMap(point);
}
@Override
public void onFailure() {
}
});
VerticalPanel panel = new VerticalPanel();
panel.setSize("500px", "600px");
map.setSize("500px", "500px");
panel.add(map);
RootPanel.get("content").add(panel);
}
private void initMap(LatLng point) {
map.setCenter(point);
map.setZoomLevel(12);
map.addMapClickHandler(new MapClickHandler() {
@Override
public void onClick(MapClickEvent event) {
final Marker marker = new
Marker(event.getLatLng());
map.addOverlay(marker);
geocoder.getLocations(event.getLatLng(), new
LocationCallback() {
@Override
public void
onSuccess(JsArray<Placemark> locations) {
VerticalPanel panel = new
VerticalPanel();
for(int i=0;
i<locations.length();i++) {
panel.add(new
Label(locations.get(i).getAddress()));
}
InfoWindow info =
map.getInfoWindow();
info.open(marker, new
InfoWindowContent(panel));
}
@Override
public void onFailure(int statusCode) {
}
});
}
});
}
}
public class DialogTest implements EntryPoint{
@Override
public void onModuleLoad() {
Anchor anotherMap = new Anchor("Show another map");
anotherMap.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
MapDialogBox dialogBox = new MapDialogBox();
dialogBox.center();
dialogBox.show();
}
});
RootPanel.get("content").add(anotherMap);
}
}
public class MapDialogBox extends DialogBox {
MapWidget map;
Geocoder geocoder = new Geocoder();
@Override
public void show() {
map = new MapWidget();
geocoder.getLatLng("Russia Saint-Petersburg", new
LatLngCallback() {
@Override
public void onSuccess(LatLng point) {
initMap(point);
}
@Override
public void onFailure() {
}
});
AbsolutePanel panel = new AbsolutePanel();
panel.setSize("400px", "400px");
map.setSize("400px", "400px");
panel.add(map);
setWidget(panel);
super.show();
}
public MapDialogBox() {
super(true);
}
private void initMap(LatLng point) {
map.setCenter(point);
map.setZoomLevel(12);
map.addMapClickHandler(new MapClickHandler() {
@Override
public void onClick(MapClickEvent event) {
final Marker marker = new
Marker(event.getLatLng());
map.addOverlay(marker);
geocoder.getLocations(event.getLatLng(), new
LocationCallback() {
@Override
public void
onSuccess(JsArray<Placemark> locations) {
VerticalPanel panel = new
VerticalPanel();
for(int i=0;
i<locations.length();i++) {
panel.add(new
Label(locations.get(i).getAddress()));
}
InfoWindow info =
map.getInfoWindow();
info.open(marker, new
InfoWindowContent(panel));
}
@Override
public void onFailure(int statusCode) {
}
});
}
});
}
}
On Jan 13, 7:11 pm, Eric Ayers <[email protected]> wrote:
> I was thinking to recreate it with a small yet complete example so we can
> understand fully what's going on. For example, you said in your last post
> that you had 2 map instances which isn't apparent from your code snippet.
>
>
>
> On Wed, Jan 13, 2010 at 10:40 AM, morfeusys <[email protected]> wrote:
> > Yes, I try to recreate it - you can see the piece of code in my first
> > post. But this problem occurs when I try to create and open window on
> > the second map.
>
> > On Jan 13, 6:08 pm, Eric Ayers <[email protected]> wrote:
> > > I don't think you can use an infowindow from one map and pass it to
> > another.
> > > I suggest you recreate the info window for each separate map instance.
>
> > > On Tue, Jan 12, 2010 at 5:06 PM, morfeusys <[email protected]> wrote:
> > > > Thanks for your answer! The code crashes only if the first map with
> > > > the same code was initialized previously. This means that I can't
> > > > initialize another map with info window if I have another map already
> > > > initialized. Is there some workaround? For example can I manualy
> > > > unwrap info window object if I would create another? Thank you.
>
> > > > On 11 янв, 21:47, Eric Ayers <[email protected]> wrote:
> > > > > What this exception means is that the same JavaScript object has been
> > > > > attempted to be 'wrapped' more than once by the JSIO library used in
> > the
> > > > > Maps API to interface with JavaScript.
>
> > > > > One divergence between the Maps JavaScript API and the GWT bindings
> > to
> > > > the
> > > > > API is that in the Maps API, there is one info window per map. The
> > GWT
> > > > > bindings make it seem as though you can make as many info window
> > objects
> > > > as
> > > > > you like, but in fact, there is only one underneath. I can see how
> > this
> > > > > might cause a problem.
>
> > > > > Can you reproduce this in a small complete sample showing both adds?
> > > > > Besides the InfoWindow thing I just mentioned, I'm wondering what
> > "Grid"
> > > > > is, as you're passing it as a parameter to construct the info window.
> > > > Also,
> > > > > make sure to step through the code to see if it is crashing in
> > > > info.open()
> > > > > somewhere or within the constructor for InfoWindowContent.
>
> > > > > -Eric.
>
> > > > > On Mon, Jan 11, 2010 at 11:03 AM, morfeusys <[email protected]>
> > wrote:
> > > > > > Hi. I found next problem with my gwt-maps based project.
> > > > > > I use several map components on one page. The both components are
> > in
> > > > > > pop-up windows. The both components should provide handler for on
> > map
> > > > > > click event.
> > > > > > When the first map component initialized - everything works ok. But
> > > > > > when the second tries to add onclick handler - the runtime error
> > > > > > occurs:
>
> > > > > > Deferred binding failed for
> > > > > > 'com.google.gwt.maps.client.impl.EventImpl' (did you forget to
> > inherit
> > > > > > a required module?)
>
> > > > > > Stack trace:
>
> > > > > > com.google.gwt.maps.jsio.client.MultipleWrapperException: null
> > > > > > at
>
> > com.google.gwt.maps.jsio.client.impl.JSONWrapperUtil.throwMultipleWrapperEx
> > > > ception
> > > > > > (JSONWrapperUtil.java:169)
> > > > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > > > > at sun.reflect.NativeMethodAccessorImpl.invoke
> > > > > > (NativeMethodAccessorImpl.java:39)
> > > > > > at sun.reflect.DelegatingMethodAccessorImpl.invoke
> > > > > > (DelegatingMethodAccessorImpl.java:25)
> > > > > > at java.lang.reflect.Method.invoke(Method.java:597)
> > > > > > at com.google.gwt.dev.shell.MethodAdaptor.invoke
> > > > > > (MethodAdaptor.java:103)
> > > > > > at com.google.gwt.dev.shell.MethodDispatch.invoke
> > > > > > (MethodDispatch.java:71)
> > > > > > at com.google.gwt.dev.shell.OophmSessionHandler.invoke
> > > > > > (OophmSessionHandler.java:157)
> > > > > > ...
>
> > > > > > My code is:
>
> > > > > > ...
> > > > > > Grid grid = new Grid(4, 2);
> > > > > > Marker marker = new Marker(point);
> > > > > > map.addOverlay(marker);
> > > > > > InfoWindow info = map.getInfoWindow();
> > > > > > info.open(marker, new InfoWindowContent(grid));
> > > > > > ...
>
> > > > > > The program crashes on line "info.open(marker, new
> > InfoWindowContent
> > > > > > (grid));". The interesting thing is that if I change the order of
> > > > > > initialization of first and second map components in pop-up
> > windows,
> > > > > > the problem occurs only on those component which was initialized
> > last.
>
> > > > > > Has anybody seen such problem?
> > > > > > Thanks.
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > "Google Web Toolkit" group.
> > > > > > To post to this group, send email to
> > > > [email protected].
> > > > > > To unsubscribe from this group, send email to
> > > > > > [email protected]<google-web-toolkit%[email protected]>
> > <google-web-toolkit%[email protected]<google-web-toolkit%[email protected]>
> > ><google-web-toolkit%2Bunsubs
> > > > [email protected]>
> > > > > > .
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/google-web-toolkit?hl=en.
>
> > > > > --
> > > > > Eric Z. Ayers
> > > > > Google Web Toolkit, Atlanta, GA USA
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Google Web Toolkit" group.
> > > > To post to this group, send email to
> > [email protected].
> > > > To unsubscribe from this group, send email to
> > > > [email protected]<google-web-toolkit%[email protected]>
> > <google-web-toolkit%[email protected]<google-web-toolkit%[email protected]>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/google-web-toolkit?hl=en.
>
> > > --
> > > Eric Z. Ayers
> > > Google Web Toolkit, Atlanta, GA USA
> > > Sign up now for Google I/O 2010: May 19-20,http://code.google.com/io
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<google-web-toolkit%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-web-toolkit?hl=en.
>
> --
> Eric Z. Ayers
> Google Web Toolkit, Atlanta, GA USA
> Sign up now for Google I/O 2010: May 19-20,http://code.google.com/io
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.