Example usage for com.google.gwt.maps.client MapTypeId MapTypeId

List of usage examples for com.google.gwt.maps.client MapTypeId MapTypeId

Introduction

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

Prototype

MapTypeId

Source Link

Usage

From source file:com.google.mobile.trippy.web.client.view.MapView.java

License:Apache License

private MapWidget createMapWidget(final HasLatLng center, final int zoom) {

    String mapTypeId = new MapTypeId().getRoadmap();

    HasNavigationControlOptions navOptions = new NavigationControlOptions(new ControlPositionImpl(),
            new NavigationControlStyleImpl());
    navOptions.setPosition(ControlPosition.BOTTOM);
    navOptions.setStyle(NavigationControlStyle.ANDROID);

    HasScaleControlOptions scaleOptions = new ScaleControlOptions(new ControlPositionImpl(),
            new ScaleControlStyleImpl());
    scaleOptions.setStyle(ScaleControlStyle.DEFAULT);

    HasMapTypeControlOptions mapTypeOptions = new MapTypeControlOptions(new ControlPositionImpl(),
            new MapTypeControlStyleImpl());
    mapTypeOptions.setStyle(MapTypeControlStyle.DROPDOWN_MENU);

    HasMapOptions options = new MapOptions();
    options.setCenter(center);//from ww  w .ja  v  a 2s .  c  o  m
    options.setZoom(zoom);
    options.setMapTypeId(mapTypeId);
    options.setBackgroundColor("white");
    options.setNavigationControl(true);
    //    options.setNavigationControlOptions(navOptions);
    options.setScaleControl(false);
    //    options.setScaleControlOptions(scaleOptions);
    options.setMapTypeControl(true);
    options.setMapTypeControlOptions(mapTypeOptions);
    options.setDraggable(true);
    return new MapWidget(options);

}

From source file:com.mashery.examples.api.client.PopupMapWidget.java

License:Open Source License

public PopupMapWidget() {
    mapPanel = new PopupPanel(true);
    mapPanel.setAutoHideOnHistoryEventsEnabled(true);
    mapPanel.setAnimationEnabled(true);//from www  . j  a  v a2s  .c o  m

    MapOptions options = new MapOptions();
    options.setZoom(1);
    options.setCenter(new LatLng(0d, 0d));
    options.setMapTypeId(new MapTypeId().getRoadmap());
    options.setDraggable(true);
    options.setScrollwheel(true);
    options.setNavigationControl(true);
    options.setMapTypeControl(true);
    mapWidget = new MapWidget(options);
    mapWidget.setSize("512px", "512px");

    FlowPanel mapContainer = new FlowPanel();
    mapPanel.setWidget(mapContainer);
    mapContainer.add(mapWidget);

    Anchor clearMarkersLink = new Anchor("Clear Markers", "#");
    mapContainer.add(clearMarkersLink);
    clearMarkersLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            event.preventDefault();
            // there's no way to setMap(null) on a marker
            // instead, assign it to a dummy map
            MapWidget garbage = new MapWidget(new MapOptions());
            HasMap map = garbage.getMap();
            for (HasMarker marker : markers.values())
                marker.setMap(map);

            markers.clear();
        }
    });

    mapButton = new ToggleButton("Map");
    mapPanel.addAutoHidePartner(mapButton.getElement());
    mapButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (mapButton.isDown())
                mapPanel.showRelativeTo(mapButton);
            else
                mapPanel.hide();
        }
    });

    mapPanel.addCloseHandler(new CloseHandler<PopupPanel>() {
        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            mapButton.setDown(false);
        }
    });

    initWidget(mapButton);
}

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 ww w  . j  a va  2  s. 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;
}