Example usage for com.google.gwt.maps.client.overlays InfoWindowOptions newInstance

List of usage examples for com.google.gwt.maps.client.overlays InfoWindowOptions newInstance

Introduction

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

Prototype

public static final InfoWindowOptions newInstance() 

Source Link

Document

InfoWindow Options

Usage

From source file:com.google.gwt.maps.testing.client.maps.BasicMapWidget.java

License:Apache License

protected void drawInfoWindow(Marker marker, MouseEvent mouseEvent) {
    if (marker == null || mouseEvent == null) {
        return;//w  ww  .  j a va  2s.c  o m
    }

    HTML html = new HTML("You clicked on: " + mouseEvent.getLatLng().getToString());

    InfoWindowOptions options = InfoWindowOptions.newInstance();
    options.setContent(html);
    InfoWindow iw = InfoWindow.newInstance(options);
    iw.open(mapWidget, marker);
}

From source file:com.google.gwt.maps.testing.client.maps.ElevationMapWidget.java

License:Apache License

protected void drawInfoWindow(LatLng position, double elevation) {

    NumberFormat format = NumberFormat.getFormat("###");
    String elevationStr = format.format(elevation);
    String latlngStr = "[ " + format.format(position.getLatitude()) + ", "
            + format.format(position.getLongitude()) + " ]";
    String message = "Elevation " + elevationStr + "m @ " + latlngStr;

    HTML html = new HTML(message);
    InfoWindowOptions options = InfoWindowOptions.newInstance();
    options.setContent(html);/*from  w ww .j  a  va2  s. c o m*/
    InfoWindow iw = InfoWindow.newInstance(options);
    iw.setPosition(position);
    iw.open(mapWidget);
}

From source file:com.google.gwt.maps.testing.client.maps.InfoWindowMapWidget.java

License:Apache License

private void drawInfoWindowOnMapCenter() {
    HTML html = new HTML("Center: " + mapWidget.getCenter().getToString());

    InfoWindowOptions options = InfoWindowOptions.newInstance();
    options.setContent(html);/*from   www  .  j av a2s .com*/
    options.setPosition(mapWidget.getCenter());

    InfoWindow iw = InfoWindow.newInstance(options);
    iw.open(mapWidget);
}

From source file:com.google.gwt.maps.testing.client.maps.InfoWindowMapWidget.java

License:Apache License

protected void drawInfoWindow(final Marker marker, MouseEvent mouseEvent) {
    if (marker == null || mouseEvent == null) {
        return;/*  ww w . j a va2s  .  c  om*/
    }

    HTML html = new HTML(
            "Why did you click on me? <br/> You clicked on: " + mouseEvent.getLatLng().getToString());

    Button b1 = new Button("b1");
    b1.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("b1 clicked");
        }
    });

    Button b2 = new Button("b2");
    b2.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("b2 clicked");
        }
    });

    VerticalPanel vp = new VerticalPanel();
    vp.add(html);
    vp.add(b1);
    vp.add(b2);

    InfoWindowOptions options = InfoWindowOptions.newInstance();
    options.setContent(vp);

    InfoWindow iw = InfoWindow.newInstance(options);
    iw.open(mapWidget, marker);

    // If you want to clear widgets, Use options.clear() to remove the widgets
    // from map
    // options.clear();
}

From source file:com.google.sampling.experiential.client.ChartPanel.java

License:Open Source License

private void openInfoWindowForMarker(final EventDAO eventRating, final Marker marker) {
    InfoWindowOptions options = InfoWindowOptions.newInstance();
    options.setContent(createInfoWindowForEvent(eventRating));
    InfoWindow iw = InfoWindow.newInstance(options);
    iw.open(map, marker);//from  w  ww. ja  va2s .c  o  m
}

From source file:gov.nist.spectrumbrowser.client.SensorGroupMarker.java

License:Open Source License

public InfoWindow getInfoWindow(String message) {
    if (infoWindow == null) {
        LatLng northeast = SpectrumBrowserShowDatasets.getMap().getBounds().getNorthEast();
        LatLng southwest = SpectrumBrowserShowDatasets.getMap().getBounds().getSouthWest();
        double delta = northeast.getLatitude() - southwest.getLatitude();
        int height = SpectrumBrowser.MAP_HEIGHT;
        // should be the height of the icon.
        int desiredPixelOffset = 15;
        double latitudeOffset = delta / height * desiredPixelOffset;
        InfoWindowOptions iwo = InfoWindowOptions.newInstance();
        iwo.setPosition(LatLng.newInstance(lat + latitudeOffset, lon));
        iwo.setDisableAutoPan(true);/* w  w  w.  ja  v a 2  s  . c  om*/
        iwo.setContent(message);
        infoWindow = InfoWindow.newInstance(iwo);
    }
    return infoWindow;
}

From source file:gov.nist.spectrumbrowser.client.SensorInfoDisplay.java

License:Open Source License

public InfoWindow getInfoWindow() {
    LatLng northeast = SpectrumBrowserShowDatasets.getMap().getBounds().getNorthEast();
    LatLng southwest = SpectrumBrowserShowDatasets.getMap().getBounds().getSouthWest();
    double delta = northeast.getLatitude() - southwest.getLatitude();
    int height = SpectrumBrowser.MAP_HEIGHT;
    // should be the height of the icon.
    int desiredPixelOffset = 15;
    double latitudeOffset = delta / height * desiredPixelOffset;
    InfoWindowOptions iwo = InfoWindowOptions.newInstance();

    iwo.setPosition(LatLng.newInstance(getLatLng().getLatitude() + latitudeOffset, getLatLng().getLongitude()));
    iwo.setDisableAutoPan(true);//from  w w w  .  j  a v a  2 s.co  m
    iwo.setContent(sensorInfo.getSensorDescription());
    return InfoWindow.newInstance(iwo);
}

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

/**
 * Instantiates a new map field.// ww  w .  j av  a  2  s.c om
 *
 * @param form is the form or other HasComponents element that contains the field.
 * @param permission that controls the visibility of the field.
 * @param tab index of the field.
 */
public MapField(HasComponents form, short[] permission, int tab) {
    initialize(panel, form, permission, CSS.cbtMapField());

    super.setDefaultValue(LatLng.newInstance(0.0, 0.0));

    addressLabel.addStyleName(CSS.cbtMapFieldLabel());
    addressBox.addStyleName(CSS.cbtLocationFieldField());
    addressBox.addBlurHandler(new BlurHandler() {
        @Override
        public void onBlur(BlurEvent event) {
            setName(addressBox.getText());
        }
    });

    addressBox.addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                setName(addressBox.getText());
            }
        }
    });

    latitudeLabel.addStyleName(CSS.cbtMapFieldLabel());
    latitudeBox.addStyleName(CSS.cbtMapFieldLatLng());
    latitudeBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            Double latitude = LF.parse(latitudeBox.getText());
            if (latitude < -90.0 || latitude > 90.0) {
                addMessage(Level.ERROR, CONSTANTS.errPositionLatitude(), latitudeBox);
            } else {
                setValue(LatLng.newInstance(latitude, marker.getPosition().getLongitude()));
            }
        }
    });

    longitudeLabel.addStyleName(CSS.cbtMapFieldLabel());
    longitudeBox.addStyleName(CSS.cbtMapFieldLatLng());
    longitudeBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            Double longitude = LF.parse(longitudeBox.getText());
            if (longitude < -180.0 || longitude > 180.0) {
                addMessage(Level.ERROR, CONSTANTS.errPositionLongitude(), longitudeBox);
            } else {
                setValue(LatLng.newInstance(marker.getPosition().getLatitude(), longitude));
            }
        }
    });

    position.addStyleName(CSS.cbtMapFieldTitle());
    position.add(addressLabel);
    position.add(addressBox);
    position.add(latitudeLabel);
    position.add(latitudeBox);
    position.add(longitudeLabel);
    position.add(longitudeBox);
    position.add(lock);

    panel.add(position);

    MapOptions mapOptions = MapOptions.newInstance();
    mapOptions.setDraggableCursor("crosshair");
    mapOptions.setDraggingCursor("text");
    mapOptions.setCenter(LatLng.newInstance(0.0, 0.0));
    mapOptions.setDraggable(true);
    mapOptions.setDisableDoubleClickZoom(true);
    //      mapOptions.setHeading(heading);
    mapOptions.setKeyboardShortcuts(false);
    mapOptions.setMapMaker(true);
    mapOptions.setMapTypeControl(true);
    mapOptions.setMapTypeId(mapTypeId);
    mapOptions.setNoClear(false);
    mapOptions.setOverviewMapControl(false);
    //      mapOptions.setMapTypeControlOptions(MapTypeControlOptions.)
    mapOptions.setPanControl(true);
    //      mapOptions.setPanControlOptions(panControlOptions);
    mapOptions.setRotateControl(false);
    //      mapOptions.setRotateControlOptions(rotateControlOptions)
    mapOptions.setScaleControl(true);
    //      mapOptions.setScaleControlOptions(scaleControlOptions)
    mapOptions.setScrollWheel(scrollWheel);
    //      StreetViewPanoramaImpl streetView = StreetViewPanoramaImpl.newInstance(field.getElement(), options);
    //      mapOptions.setStreetView(streetView);
    mapOptions.setStreetViewControl(streetView);
    //      mapOptions.setStreetViewControlOptions(streetViewControlOptions)
    //      mapOptions.setStyles(styles)
    mapOptions.setZoom(15);
    mapOptions.setZoomControl(true);

    map = MapWidget.newInstance(MapImpl.newInstance(field.getElement(), mapOptions));

    map.addClickHandler(new ClickMapHandler() {
        public void onEvent(ClickMapEvent event) {
            if (isEnabled()) {
                setValue(event.getMouseEvent().getLatLng());
                fireChange(MapField.this);
            }
        }
    });
    panel.add(field);

    emptyValue.addStyleName(CSS.cbtMapFieldEmpty());
    emptyValue.setVisible(false);
    panel.add(emptyValue);

    InfoWindowOptions infowindowOpts = InfoWindowOptions.newInstance();
    infowindowOpts.setMaxWidth(100);
    infowindowOpts.setPosition(defaultValue);
    infoWindow = InfoWindow.newInstance(infowindowOpts);
}

From source file:org.rebioma.client.MapView.java

License:Apache License

protected void mapGeocoderResult(JsArray<com.google.gwt.maps.client.services.GeocoderResult> results) {
    String address = geocoder.getAddress();
    StringBuilder sb = new StringBuilder();
    LatLng point = null;/*from   w  ww. j  a  va 2  s  .  c  o  m*/
    for (int i = 0; i < results.length(); i++) {
        com.google.gwt.maps.client.services.GeocoderResult geoResult = results.get(i);
        point = geoResult.getGeometry().getLocation();
        MapGeocoderResult result = new MapGeocoderResult(point, address);
        sb.append(result);
        InfoWindowOptions contentOptions = InfoWindowOptions.newInstance();
        contentOptions.setContent(result);
        contentOptions.setPosition(point);
        final InfoWindow content = InfoWindow.newInstance(contentOptions);
        if (geocoderMarkers != null) {
            for (Marker marker : geocoderMarkers) {
                marker.setMap((MapWidget) null);
            }
        }
        Marker geocoderMarker = GeocoderControl.createMarker(point, address);
        geocoderMarker.setMap(map);
        geocoderMarker.addClickHandler(new ClickMapHandler() {
            @Override
            public void onEvent(ClickMapEvent event) {
                closeInfoWindows();
                content.open(map);
                infoWindows.add(content);
            }
        });
        geocoderMarkers.add(geocoderMarker);
    }
    if (results.length() == 1 && point != null) {
        map.setCenter(point);
    }
}

From source file:org.rebioma.client.MapView.java

License:Apache License

private void showWindowInfo(OccurrenceMarkerManager occurrenceMarkerManager) {
    if (summaryContent == null) {
        summaryContent = new OccurrenceSummaryContent();
    }/*from   www .  j  a  va  2s  . c o m*/
    closeInfoWindows();
    summaryContent.loadOccurrenceInfo(occurrenceMarkerManager.getOccurrence());
    //parent.getAbsoluteLeft();
    InfoWindowOptions infoWindowOptions = InfoWindowOptions.newInstance();
    infoWindowOptions.setPosition(occurrenceMarkerManager.getMarker().getPosition());
    try {
        infoWindowOptions.setContent(summaryContent);
    } catch (JavaScriptException e) {
        //on reessaie
        //TODO determiner pourquoi pour un nombre paire(2ime, 4ime, ...) d'execution, il y a une JavaScriptException
        infoWindowOptions.setContent(summaryContent);
    }

    InfoWindow infoWindow = InfoWindow.newInstance(infoWindowOptions);
    infoWindow.open(map);
    infoWindows.add(infoWindow);
}