Example usage for com.google.gwt.maps.client InfoWindowContent setMaxContent

List of usage examples for com.google.gwt.maps.client InfoWindowContent setMaxContent

Introduction

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

Prototype

public void setMaxContent(Widget windowMaximizedContent) 

Source Link

Document

Specifies content to be shown when the InfoWindow is maximized.

Usage

From source file:com.google.gwt.maps.sample.hellomaps.client.InfoWindowDemo.java

License:Apache License

/**
 * Display one of the info Window test cases.
 *//*from   ww  w  .ja v  a  2  s  .  c  o m*/
private void displayInfoWindow() {

    // pop down the existing info window.
    if (info != null) {
        info.close();
    }

    info = map.getInfoWindow();
    String selection = actionListBox.getItemText(actionListBox.getSelectedIndex());

    if (selection == null) {
        return;
    }

    InfoWindowContent content;

    if (selection.equals(TEST_MAX_CONTENT)) {

        // Demonstrate the use of the maxTitle and maxContent properties
        HTML htmlWidget = new HTML(
                "<h1>ATTENTION PLEASE</h1>" + "<p> I have a few things to say to you (click maximize.)</p>");
        content = new InfoWindowContent(htmlWidget);
        content.setMaxContent("<p>Now is the time for all good men to come to the"
                + " aid of their country because we hold these truths to be self"
                + " evident, that I have a dream, that one day our children and our"
                + " children's children will tear down this wall!</p>"
                + "<p>Now is the time for all good men to come to the"
                + " aid of their country because we hold these truths to be self"
                + " evident, that I have a dream, that one day our children and our"
                + " children's children will tear down this wall!</p>");
        content.setMaxTitle("ATTENTION PLEASE");

    } else if (selection.equals(TEST_IMAGE)) {

        // An image that isn't loaded yet doesn't work well sometimes
        // Specify the width and height to work around this.
        HTML htmlWidget = new HTML("<img src=\"boot.jpg\" width=\"235\" height=\"287\">");
        content = new InfoWindowContent(htmlWidget);
    } else if (selection.equals(TEST_NO_CLICK)) {

        // Demonstrates setting the info window to stay "sticky" and not
        // automatically close when the user clicks on the maps window.
        HTML htmlWidget = new HTML("<h1>STICKY INFO WINDOW</h1>"
                + "<p> Click if you must, you won't get rid of me that easily.</p>");
        content = new InfoWindowContent(htmlWidget);
        content.setNoCloseOnClick(true);
    } else if (selection.equals(TEST_TABS)) {

        // Display tabs in the InfoWindow
        content = displayInfoWindowTabs();
    } else if (selection.equals(TEST_MAX_TITLE_CONTENT_WIDGET)) {

        // Display the maximized content using widgets instead of strings.
        content = displayInfoWindowMaxWidget();
    } else if (selection.equals(TEST_MAP_BLOWUP)) {

        // Display a Map Blowup Window
        content = new InfoWindowContent.MapBlowupContent();
    } else {

        // The default case
        Tree tree = new Tree();
        TreeItem foo = new TreeItem("Foo");
        tree.addItem(foo);
        TreeItem bar = new TreeItem("bar");
        foo.addItem(bar);
        bar.addItem("baz");
        bar.addItem("gwt");
        // max-height must be set in advance so info window is sized appropriately
        tree.setSize("217px", "104px");
        content = new InfoWindowContent(tree);
    }

    info.open(map.getCenter(), content);
}

From source file:com.google.gwt.maps.sample.hellomaps.client.InfoWindowDemo.java

License:Apache License

private InfoWindowContent displayInfoWindowMaxWidget() {
    final InfoWindowContent content = new InfoWindowContent("There's more to see (hit the maximize button)");
    content.setMaxTitle(new HTML("<i>Maximized Italic Boots</i>"));
    VerticalPanel panel = new VerticalPanel();
    panel.add(new Image("boot.jpg"));
    Button b = new Button("Click for Message");
    final Label l = new Label();
    HorizontalPanel hp = new HorizontalPanel();
    hp.add(b);/*from  ww w  .j av a  2 s . co m*/
    hp.add(l);
    l.getElement().getStyle().setPropertyPx("margin", 7);
    b.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            GWT.log("Got click in maximized window.", null);
            if (l.getText().equals("")) {
                l.setText("Hello World!");
            } else {
                l.setText("");
            }
        }
    });
    panel.add(hp);
    panel.setSpacing(10);
    content.setMaxContent(panel);
    return content;
}

From source file:com.google.gwt.maps.sample.hellomaps.client.MapEventDemo.java

License:Apache License

/**
 * Create a panel of buttons to use to perform various actions on the marker.
 *///from w ww .  ja  v a  2 s . c om
private Panel createActionButtons() {
    VerticalPanel vp = new VerticalPanel();
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(10);

    vp.add(hp);

    // Create a button to hide/show the marker
    final Button hideButton = new Button("Hide Marker");
    hideButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            boolean state = !marker.isVisible();
            marker.setVisible(state);
            if (state) {
                hideButton.setText("Hide Marker");
            } else {
                hideButton.setText("Show Marker");
            }
        }
    });
    hp.add(hideButton);

    // Create a button to remove the marker from the map.
    final Button removeButton = new Button("Remove Marker");
    removeButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            if (!markerRemoved) {
                map.removeOverlay(marker);
                removeButton.setText("Add Marker");
            } else {
                map.addOverlay(marker);
                removeButton.setText("Remove Marker");
            }
            hideButton.setEnabled(markerRemoved);
            markerRemoved = !markerRemoved;
        }
    });
    hp.add(removeButton);

    // Create a button to hide/show the polygon
    final Button hidePolygonButton = new Button("Hide Polygon");
    hidePolygonButton.setEnabled(false);
    hidePolygonButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            boolean state = !polygon.isVisible();
            polygon.setVisible(state);
            if (state) {
                hidePolygonButton.setText("Hide Polygon");
            } else {
                hidePolygonButton.setText("Show Polygon");
            }
        }
    });
    hp.add(hidePolygonButton);

    // Create a button to remove the polygon from the map.
    final Button removePolygonButton = new Button("Add Polygon");
    removePolygonButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            if (!polygonRemoved) {
                map.removeOverlay(polygon);
                removePolygonButton.setText("Add Polygon");
            } else {
                map.addOverlay(polygon);
                removePolygonButton.setText("Remove Polygon");
            }
            hidePolygonButton.setEnabled(polygonRemoved);
            polygonRemoved = !polygonRemoved;
        }
    });
    hp.add(removePolygonButton);

    // Create a button to hide/show the polyline
    final Button hidePolylineButton = new Button("Hide Polyline");
    hidePolylineButton.setEnabled(false);
    hidePolylineButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            boolean state = !polyline.isVisible();
            polyline.setVisible(state);
            if (state) {
                hidePolylineButton.setText("Hide Polyline");
            } else {
                hidePolylineButton.setText("Show Polyline");
            }
        }
    });
    hp.add(hidePolylineButton);

    // Create a button to remove the polyline from the map.
    final Button removePolylineButton = new Button("Add Polyline");
    removePolylineButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            if (!polylineRemoved) {
                map.removeOverlay(polyline);
                removePolylineButton.setText("Add Polyline");
            } else {
                map.addOverlay(polyline);
                removePolylineButton.setText("Remove Polyline");
            }
            hidePolylineButton.setEnabled(polylineRemoved);
            polylineRemoved = !polylineRemoved;
        }
    });
    hp.add(removePolylineButton);

    final Button clearOverlaysButton = new Button("Clear Overlays");
    clearOverlaysButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            map.clearOverlays();
        }
    });

    hp.add(clearOverlaysButton);

    hp = new HorizontalPanel();
    hp.setSpacing(10);
    vp.add(hp);

    final Button infoWindowButton = new Button("Show InfoWindow");
    infoWindowButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            InfoWindow info = map.getInfoWindow();
            InfoWindowContent content = new InfoWindowContent("Hello Maps!");
            content.setMaxContent("Hello Maps - more content");
            content.setMaxTitle("Hello Maps");
            info.open(map.getCenter(), content);
        }
    });
    hp.add(infoWindowButton);

    final Button mInfoWindowButton = new Button("Marker InfoWindow");
    mInfoWindowButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            InfoWindow info = map.getInfoWindow();
            InfoWindowContent content = new InfoWindowContent("Hello Maps!");
            content.setMaxContent("Hello Maps - more content");
            content.setMaxTitle("Hello Maps");
            info.open(marker, content);
        }
    });
    hp.add(mInfoWindowButton);

    final Button mapTypeButton = new Button("Add Map Type");
    mapTypeButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            if (!mapTypeRemoved) {
                map.addMapType(MapType.getSkyVisibleMap());
                mapTypeButton.setText("Remove MapType");
            } else {
                map.removeMapType(MapType.getSkyVisibleMap());
                mapTypeButton.setText("Add MapType");
            }
            mapTypeRemoved = !mapTypeRemoved;
        }

    });
    hp.add(mapTypeButton);

    // Create a button to clear out the table.
    final Button clearTableButton = new Button("Clear Table");
    clearTableButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            clearListenerTable();
        }
    });
    hp.add(clearTableButton);

    return vp;
}