hugoloza / gwt-google-apis

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

OnSuccess of GeoXmlOverlay.load is looping #459

Closed GoogleCodeExporter closed 9 years ago

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

Detailed description:

Suppose I have the following code when loading GeoXmlOverlay :

  GeoXmlOverlay.load(url, new GeoXmlLoadCallback() { 
            @Override 
            public void onFailure(String s, Throwable throwable) { 
                Window.alert("Sorry, your map overlay failed"); 
                GWT.log(s); 
                if (throwable != null) { 
                    throwable.printStackTrace(); 
                } 
            } 

            @Override 
            public void onSuccess(final String s, final GeoXmlOverlay geoXmlOverlay) { 
                GWT.log("Overlay success for " + s); 
                map.addOverlay(geoXmlOverlay); 
            } 
        }); 

Something strange is happening where the onSucess method is called again when 
map.addOverlay(geoXmlOverlay) is called.

if map.addOverlay(geoXmlOverlay) is not called, no looping occurs.

A detailed explanation can also be found here :

http://groups.google.com/group/gwt-google-apis/browse_thread/thread/b8fbc5af81d0
e500/734c663bf414aa2e?#734c663bf414aa2e

Workaround if you have one:

           public void onSuccess(final String s, final GeoXmlOverlay geoXmlOverlay) { 
                GWT.log("Overlay success for " + s);
                if(!overlayCache.contains(geoXmlOverlay)){
                  overlayCache.add(geoXmlOverlay);
                  map.addOverlay(geoXmlOverlay);
                } 
            } 
Where overlayCache is just an ArrayList<GeoXmlOverlay>.  This code still 
results in the onSuccess method being called twice.  The second time, the cache 
has the overlay so map.addOverlay is not called. 

Links to the relevant GWT Developer Forum posts:

http://groups.google.com/group/gwt-google-apis/browse_thread/thread/b8fbc5af81d0
e500/734c663bf414aa2e?#734c663bf414aa2e

Original issue reported on code.google.com by john.d.r...@gmail.com on 21 Mar 2011 at 4:10

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

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