Example usage for com.google.gwt.maps.client.event MouseEventCallback MouseEventCallback

List of usage examples for com.google.gwt.maps.client.event MouseEventCallback MouseEventCallback

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.event MouseEventCallback MouseEventCallback.

Prototype

MouseEventCallback

Source Link

Usage

From source file:com.google.mobile.trippy.web.client.view.MapView.java

License:Apache License

@Override
public void setMarkerClickListener(final HasMarker marker, final MarkerClickListener markerClickListener) {
    Event.addListener(marker, HasMarker.Event.CLICK.getValue(), new MouseEventCallback() {

        @Override//from w  ww.ja  va2  s.c  o  m
        public void callback(HasMouseEvent event) {
            markerClickListener.onMarkerClick(marker);
        }
    });
}

From source file:com.google.mobile.trippy.web.client.view.MapView.java

License:Apache License

@Override
public void setMapClickListener(final MapClickListener mapClickListener) {
    Event.addListener(getMap(), "click", new MouseEventCallback() {

        @Override//from  ww  w. j  a v  a  2  s .  co  m
        public void callback(HasMouseEvent event) {
            mapClickListener.onMapClick(event.getLatLng());
        }
    });
}

From source file:org.opendatakit.aggregate.client.popups.VisualizationPopup.java

License:Apache License

private MapWidget createMap() {
    int latIndex = findGpsIndex(geoPoints.getElementKey(), GeoPointConsts.GEOPOINT_LATITUDE_ORDINAL_NUMBER);
    int lonIndex = findGpsIndex(geoPoints.getElementKey(), GeoPointConsts.GEOPOINT_LONGITUDE_ORDINAL_NUMBER);

    // check to see if we have lat & long, if not display erro
    if (latIndex < 0 || lonIndex < 0) {
        String error = "ERROR:";
        if (latIndex < 0) {
            error = error + " The Latitude Coordinate is NOT included in the Filter.";
        }/* ww  w.  j  av a2  s .c om*/
        if (lonIndex < 0) {
            error = error + " The Longitude Coordinate is NOT included in the Filter.";
        }

        Window.alert(error);
        return null;
    }

    // create a center point, stop at the first gps point found
    LatLng center = new LatLng(0.0, 0.0);
    for (SubmissionUI sub : submissions) {
        LatLng gpsPoint = getLatLonFromSubmission(latIndex, lonIndex, sub);
        if (gpsPoint != null) {
            center = gpsPoint;
            break;
        }
    }

    // create mapping area
    final MapOptions options = new MapOptions();
    options.setCenter(center);
    MapTypeId id = new MapTypeId();
    options.setMapTypeId(id.getRoadmap());
    options.setZoom(6);
    options.setMapTypeControl(true);
    options.setNavigationControl(true);
    options.setScaleControl(true);
    final MapWidget mapWidget = new MapWidget(options);
    mapWidget.setSize("100%", "100%");

    final HasMap map = mapWidget.getMap();

    // create the markers
    for (SubmissionUI sub : submissions) {
        LatLng gpsPoint = getLatLonFromSubmission(latIndex, lonIndex, sub);
        if (gpsPoint != null) {
            final Marker marker = new Marker();
            marker.setPosition(gpsPoint);
            marker.setMap(map);

            // marker needs to be added to the map before calling
            // InfoWindow.open(marker, ...)
            final SubmissionUI tmpSub = sub;
            Event.addListener(marker, "mouseover", new MouseEventCallback() {

                @Override
                public void callback(HasMouseEvent event) {
                    if (infoWindow != null) {
                        infoWindow.close();
                    }
                    infoWindow = new InfoWindow();
                    InfoContentSubmission w = createInfoWindowWidget(tmpSub);
                    HTMLPanel container = new HTMLPanel("<div></div>");
                    container.add(w);
                    infoWindow.setContent(container.getElement().getInnerHTML());
                    infoWindow.open(map, marker);
                }
            });

            Event.addListener(marker, "mouseout", new MouseEventCallback() {

                @Override
                public void callback(HasMouseEvent event) {
                    if (!mapMarkerClicked) {
                        if (infoWindow != null) {
                            infoWindow.close();
                            infoWindow = null;
                        }
                    }
                    mapMarkerClicked = false;
                }
            });

            Event.addListener(marker, "click", new MouseEventCallback() {

                @Override
                public void callback(HasMouseEvent event) {
                    mapMarkerClicked = true;
                }

            });
        }
    }
    return mapWidget;
}