Example usage for com.google.gwt.maps.client.overlays MarkerOptions setVisible

List of usage examples for com.google.gwt.maps.client.overlays MarkerOptions setVisible

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.overlays MarkerOptions setVisible.

Prototype

public final native void setVisible(boolean visible) ;

Source Link

Document

sets If true, the marker is visible

Usage

From source file:net.cbtltd.client.field.MapField.java

/**
 * Adds a marker./* w  w  w. ja v a 2 s . c o  m*/
 *
 * @param value the position of the marker
 * @param text the text when clicked
 * @return the marker
 */
public Marker addMarker(LatLng value, String text) {
    if (value == null) {
        return null;
    }
    MarkerOptions markerOptions = MarkerOptions.newInstance();
    markerOptions.setClickable(true);
    markerOptions.setDraggable(isEnabled());
    markerOptions.setTitle(text);
    markerOptions.setPosition(value);
    markerOptions.setMap(map);
    markerOptions.setVisible(visible);
    marker = Marker.newInstance(markerOptions);
    markers.add(marker);

    marker.addClickHandler(new ClickMapHandler() {
        public void onEvent(ClickMapEvent event) {
            setValue(event.getMouseEvent().getLatLng());
        }
    });

    marker.addDragEndHandler(new DragEndMapHandler() {
        public void onEvent(DragEndMapEvent event) {
            setValue(marker.getPosition());
            fireChange(MapField.this);
        }
    });

    marker.addMouseOverHandler(new MouseOverMapHandler() {
        public void onEvent(MouseOverMapEvent event) {
            if (markerFunction != null) {
                markerFunction.onFocus(event);
            }
        }
    });

    marker.addMouseOutMoveHandler(new MouseOutMapHandler() {
        public void onEvent(MouseOutMapEvent event) {
            if (markerFunction != null) {
                markerFunction.onBlur(event);
            }
        }
    });
    return marker;
}