Hello pfdevil,

Set a breakpoint in your MapClickHandler instance with a Java debugger (like
running in Debug mode in Eclipse) to get a handle on what your code is
doing.   I see one odd thing.  Although it isn't necessarily wrong, you're
creating a new marker every time the handler goes off.  You may find that an
exception is happening inside the handler before you get a chance to remove
the overlay.

-Eric.

On Thu, Dec 17, 2009 at 8:50 AM, pfdevil <[email protected]> wrote:

> Hello
>
> I have an issue with an marker that does not want to closed when
> clicked. I copied the code from this tutorial.
>
>
> http://gwt.google.com/samples/HelloMaps-1.0.1/HelloMaps.html#Click%20Handling
>
> Here is my code:
>
> public class SimpleMaps implements EntryPoint{
>        private InfoWindow info = null;
>        private Marker newMarker = null;
>        InfoWindowContent infoWindowContent = null;
>
>        /**
>         * This is the entry point method.
>         */
> public void onModuleLoad() {
>        LatLng cawkrCity = LatLng.newInstance(39.509, -98.434);
>        VerticalPanel verticalPanel = new VerticalPanel();
>
>        verticalPanel.addStyleName("verticalPanel");
>
>        MapWidget map = new MapWidget(cawkrCity, 4);
>
>        HTML htmlWidget = new HTML("<b> Write a message </b>");
>
>        verticalPanel.add(htmlWidget);
>
>        info = map.getInfoWindow();
>
>        infoWindowContent = new InfoWindowContent(verticalPanel);
>
>        map.setUIToDefault();
>
>        map.addStyleName("mapContainer");
>
>        map.setSize("500px", "300px");
>
>
>        map.addMapClickHandler(new MapClickHandler() {
>            public void onClick(MapClickEvent e) {
>              MapWidget sender = e.getSender();
>              Overlay overlay = e.getOverlay();
>              LatLng point = e.getLatLng();
>
>              newMarker = new Marker(point);
>
>
>              if (overlay != null && overlay instanceof Marker) {
>                sender.removeOverlay(overlay);
>
>              } else {
>                sender.addOverlay(newMarker);
>                info.open(newMarker, infoWindowContent);
>
>              }
>            }
>          });
>
>
>        RootPanel.get("mapContainer").add(map);
>
>        }
>
> }
>
> --
>
> 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

--

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.


Reply via email to