Example usage for com.google.gwt.maps.client MapType getHybridMap

List of usage examples for com.google.gwt.maps.client MapType getHybridMap

Introduction

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

Prototype

public static MapType getHybridMap() 

Source Link

Document

Returns a map type that shows transparent street maps over Google Earth satellite images.

Usage

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

License:Apache License

private void displayOverlay() {

    map.clearOverlays();/* w ww .  j ava  2  s  .co m*/

    LatLngBounds bounds = map.getBounds();
    LatLng southWest = bounds.getSouthWest();
    LatLng northEast = bounds.getNorthEast();
    double lngSpan = northEast.getLongitude() - southWest.getLongitude();
    double latSpan = northEast.getLatitude() - southWest.getLatitude();

    LatLng[] points = new LatLng[NUM_POINTS];

    for (int i = 0; i < NUM_POINTS; i++) {
        points[i] = LatLng.newInstance(southWest.getLatitude() + latSpan * Math.random(),
                southWest.getLongitude() + lngSpan * Math.random());
        GWT.log("points[" + i + "] = " + points[i] + " z-index = " + Marker.getZIndex(points[i].getLatitude()),
                null);
    }

    OverlayDemos selected = OverlayDemos.values()[actionListBox.getSelectedIndex()];

    switch (selected) {
    case TEST_TEN_MARKERS: {
        // Add markers in random locations on the map
        for (int i = 0; i < NUM_POINTS; i++) {
            map.addOverlay(new Marker(points[i]));
        }
    }
        break;

    case TEST_POLYLINE_ONE: {
        // Add a polyline with NUM_POINTS random points. Sort the points by
        // longitude so that the line does not intersect itself.
        Arrays.sort(points, new Comparator<LatLng>() {
            public int compare(LatLng p1, LatLng p2) {
                return new Double(p1.getLongitude()).compareTo(new Double(p2.getLongitude()));
            }
        });
        Polyline pline = new Polyline(points);
        map.addOverlay(pline);
        if (pline.getVertexCount() != NUM_POINTS) {
            Window.alert("Created polyline with " + NUM_POINTS + " vertices, but now it has "
                    + pline.getVertexCount());
        }
    }
        break;

    case TEST_POLYLINE_ENCODED: {
        // Add a polyline encoded in a string
        map.setCenter(LatLng.newInstance(40.71213418976525, -73.96785736083984), 15);
        Polyline pline = Polyline.fromEncoded("#3333cc", 10, 1.0, ENCODED_POINTS, 32, ENCODED_LEVELS, 4);
        map.addOverlay(pline);
    }
        break;
    case TEST_POLYLINE_GEODESIC: {
        LatLng nycToZurich[] = { LatLng.newInstance(40.75, -73.90), // New York
                LatLng.newInstance(47.3, 8.5) // Zurich
        };
        map.setCenter(LatLng.newInstance(40, -25), 2);
        Polyline pline = new Polyline(nycToZurich, "#FF0000", 1, .75, PolylineOptions.newInstance(false, true));
        map.addOverlay(pline);
    }
        break;
    case TEST_POLYLINE_ENCODED_TRANSPARENT: {
        // Add a polyline with transparency
        map.setCenter(LatLng.newInstance(40.71213418976525, -73.96785736083984), 15);
        Polyline pline = Polyline.fromEncoded(ENCODED_POINTS, 32, ENCODED_LEVELS, 4);
        map.addOverlay(pline);
    }
        break;

    case TEST_POLYGON_ENCODED: {
        // Add a polygon encoded as a series of polylines.
        map.setCenter(LatLng.newInstance(33.75951619957536, -84.39289301633835), 20);
        EncodedPolyline[] polylines = new EncodedPolyline[2];
        polylines[0] = EncodedPolyline.newInstance("au`mEz_bbO?sAbA@?pAcA?", 2, "BBBBB", 1, "#ff0000", 2, 0.9);

        polylines[1] = EncodedPolyline.newInstance("{t`mEt_bbO?eAx@??dAy@?", 2, "BBBBB", 1);
        polylines[1].setColor("#ff0000");
        polylines[1].setWeight(2);
        polylines[1].setOpacity(0.7);

        Polygon theFountain = Polygon.fromEncoded(polylines, true, "#ff0000", 0.2, true);
        map.addOverlay(theFountain);
        map.setCurrentMapType(MapType.getHybridMap());
    }
        break;

    default:
        Window.alert("Cannot handle selection: " + selected.valueOf());
        break;
    }
}

From source file:org.sigmah.client.page.map.MapPreview.java

License:Open Source License

private void changeBaseMapIfNeeded(BaseMap baseMap) {
    if (currentBaseMapId == null || !currentBaseMapId.equals(baseMap.getId())) {
        MapType baseMapType = MapTypeFactory.mapTypeForBaseMap(baseMap);
        map.addMapType(baseMapType);/*from   w ww .  j  av  a2  s .c om*/
        map.setCurrentMapType(baseMapType);
        map.removeMapType(MapType.getNormalMap());
        map.removeMapType(MapType.getHybridMap());
        currentBaseMapId = baseMap.getId();
    }
}

From source file:org.thechiselgroup.choosel.visualization_component.map.client.Map.java

License:Apache License

public String getMapType() {
    MapType mapType = map.getCurrentMapType();
    if (MapType.getNormalMap().equals(mapType)) {
        return MAP_TYPE_NORMAL;
    } else if (MapType.getSatelliteMap().equals(mapType)) {
        return MAP_TYPE_SATELLITE;
    } else if (MapType.getPhysicalMap().equals(mapType)) {
        return MAP_TYPE_PHYSICAL;
    } else if (MapType.getHybridMap().equals(mapType)) {
        return MAP_TYPE_HYBRID;
    } else {//w  ww  . j  av a  2 s  .  c om
        throw new RuntimeException("map type persistence not supported for type " + mapType.getName(false));
    }
}

From source file:org.thechiselgroup.choosel.visualization_component.map.client.Map.java

License:Apache License

public void setMapType(String mapTypeID) {
    if (MAP_TYPE_NORMAL.equals(mapTypeID)) {
        map.setCurrentMapType(MapType.getNormalMap());
    } else if (MAP_TYPE_SATELLITE.equals(mapTypeID)) {
        map.setCurrentMapType(MapType.getSatelliteMap());
    } else if (MAP_TYPE_PHYSICAL.equals(mapTypeID)) {
        map.setCurrentMapType(MapType.getPhysicalMap());
    } else if (MAP_TYPE_HYBRID.equals(mapTypeID)) {
        map.setCurrentMapType(MapType.getHybridMap());
    } else {/*from ww  w .  ja v a2 s . c om*/
        throw new RuntimeException("map type persistence not supported for type " + mapTypeID);
    }
}