Example usage for com.google.gwt.maps.client.events.weatherlibmouse WeatherMouseMapEvent getLatLng

List of usage examples for com.google.gwt.maps.client.events.weatherlibmouse WeatherMouseMapEvent getLatLng

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.events.weatherlibmouse WeatherMouseMapEvent getLatLng.

Prototype

public final LatLng getLatLng() 

Source Link

Document

The position at which to anchor an info window on the clicked feature.

Usage

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

License:Apache License

private void drawMap() {
    // zoom out for the clouds
    LatLng center = LatLng.newInstance(47.11, -4.91);
    MapOptions opts = MapOptions.newInstance();
    opts.setZoom(3);/*from  w  w w .  j  a  v  a2  s .  c o  m*/
    opts.setCenter(center);
    opts.setMapTypeId(MapTypeId.SATELLITE);

    mapWidget = new MapWidget(opts);
    pWidget.add(mapWidget);
    mapWidget.setSize("750px", "500px");

    // add weather conditions layer
    WeatherLayerOptions options2 = WeatherLayerOptions.newInstance();
    options2.setTemperatureUnits(TemperatureUnit.FAHRENHEIT);
    options2.setWindSpeedUnits(WindSpeedUnit.MILES_PER_HOUR);
    options2.setLabelColor(LabelColor.BLACK);

    WeatherLayerOptions options = WeatherLayerOptions.newInstance();
    options.setTemperatureUnits(TemperatureUnit.FAHRENHEIT);
    options.setWindSpeedUnits(WindSpeedUnit.MILES_PER_HOUR);
    options.setLabelColor(LabelColor.BLACK);

    weatherLayer = WeatherLayer.newInstance(options);
    weatherLayer.setMap(mapWidget);

    // apply clouds
    cloudLayer = CloudLayer.newInstance();
    cloudLayer.setMap(mapWidget);

    // add custom handler for clicks on weather markers
    // NOTE: this is just being cat'd to the console as an
    // example of the information you get from the event
    weatherLayer.addClickHandler(new WeatherMouseMapHandler() {

        @Override
        public void onEvent(WeatherMouseMapEvent event) {
            ConsoleLog(event.getPixelOffset().getHeight());
            ConsoleLog(event.getLatLng().getLatitude());
            ConsoleLog(event.getInfoWindowHtml());
            ConsoleLog(event.getFeatureDetails().getCurrent());
            ConsoleLog(event.getFeatureDetails().getForecast().get(0));
            ConsoleLog(event.getFeatureDetails().getLocation());
            ConsoleLog(event.getFeatureDetails().getTemperatureUnits().value());
            ConsoleLog(event.getFeatureDetails().getWindSpeedUnits().value());

            // ideally you'd intercept the propagation of the event her so you could
            // display your own custom popup, not the default one
        }
    });

}