Example usage for com.google.gwt.maps.client.base InfoWindow InfoWindow

List of usage examples for com.google.gwt.maps.client.base InfoWindow InfoWindow

Introduction

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

Prototype

public InfoWindow() 

Source Link

Usage

From source file:es.uem.geoparser.client.view.MapViewImpl.java

License:Apache License

@Override
public HasInfoWindow createInfoWindow(String content) {
    final InfoWindow infoWindow = new InfoWindow();
    infoWindow.setContent(content);//from   w  w  w .ja v a  2s  .  c  o  m
    return infoWindow;
}

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.";
        }//from   w ww .  j av  a 2s . co m
        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;
}