List of usage examples for com.google.gwt.maps.client.geom LatLngBounds getNorthEast
public final native LatLng getNorthEast() ;
From source file:com.google.gwt.maps.sample.hellomaps.client.CustomOverlayDemo.java
License:Apache License
@Override public void onShow() { // The map's bounds are meaningless until the map has been added to the DOM // and sized appropriately if (firstTime) { firstTime = false;//from ww w .java 2 s . c o m LatLngBounds bounds = map.getBounds(); LatLng southWest = bounds.getSouthWest(); LatLng northEast = bounds.getNorthEast(); double lngDelta = (northEast.getLongitude() - southWest.getLongitude()) / 4; double latDelta = (northEast.getLatitude() - southWest.getLatitude()) / 4; // generate bounds that covers center map with half the width and height LatLngBounds rectBounds = LatLngBounds.newInstance( LatLng.newInstance(southWest.getLatitude() + latDelta, southWest.getLongitude() + lngDelta), LatLng.newInstance(northEast.getLatitude() - latDelta, northEast.getLongitude() - lngDelta)); map.addOverlay(new RectangleOverlay(rectBounds, 2)); } }
From source file:com.google.gwt.maps.sample.hellomaps.client.GroundOverlayDemo.java
License:Apache License
@Override public void onShow() { // The map's bounds are meaningless until the map has been added to the DOM // and sized appropriately if (firstTime) { firstTime = false;//w w w .java 2s. c o m LatLngBounds bounds = map.getBounds(); LatLng southWest = bounds.getSouthWest(); LatLng northEast = bounds.getNorthEast(); double lngDelta = (northEast.getLongitude() - southWest.getLongitude()) / 4; double latDelta = (northEast.getLatitude() - southWest.getLatitude()) / 4; // generate bounds that covers center map with half the width and height LatLngBounds rectBounds = LatLngBounds.newInstance( LatLng.newInstance(southWest.getLatitude() + latDelta, southWest.getLongitude() + lngDelta), LatLng.newInstance(northEast.getLatitude() - latDelta, northEast.getLongitude() - lngDelta)); groundOverlay = new GroundOverlay("boot.jpg", rectBounds); groundOverlay.addGroundOverlayVisibilityChangedHandler(new GroundOverlayVisibilityChangedHandler() { public void onVisibilityChanged(GroundOverlayVisibilityChangedEvent event) { if (event.isVisible()) { hideButton.setText("Hide Overlay"); } else { hideButton.setText("Show Overlay"); } } }); map.addOverlay(groundOverlay); } }
From source file:com.google.gwt.maps.sample.hellomaps.client.IconClassDemo.java
License:Apache License
@Override public void onShow() { map.clearOverlays();//from www . j a v a 2s .c om // Add 10 markers to the map at random locations LatLngBounds bounds = map.getBounds(); LatLng southWest = bounds.getSouthWest(); LatLng northEast = bounds.getNorthEast(); double lngSpan = northEast.getLongitude() - southWest.getLongitude(); double latSpan = northEast.getLatitude() - southWest.getLatitude(); for (int i = 0; i < 10; i++) { LatLng point = LatLng.newInstance(southWest.getLatitude() + latSpan * Math.random(), southWest.getLongitude() + lngSpan * Math.random()); map.addOverlay(createMarker(point, i)); } }
From source file:com.google.gwt.maps.sample.hellomaps.client.IconDemo.java
License:Apache License
@Override public void onShow() { map.clearOverlays();// ww w .j a v a 2 s. c o m // Create our "tiny" marker icon Icon icon = Icon.newInstance("http://labs.google.com/ridefinder/images/mm_20_red.png"); icon.setShadowURL("http://labs.google.com/ridefinder/images/mm_20_shadow.png"); icon.setIconSize(Size.newInstance(12, 20)); icon.setShadowSize(Size.newInstance(22, 20)); icon.setIconAnchor(Point.newInstance(6, 20)); icon.setInfoWindowAnchor(Point.newInstance(5, 1)); // Add 10 markers to the map at random locations LatLngBounds bounds = map.getBounds(); LatLng southWest = bounds.getSouthWest(); LatLng northEast = bounds.getNorthEast(); double lngSpan = northEast.getLongitude() - southWest.getLongitude(); double latSpan = northEast.getLatitude() - southWest.getLatitude(); MarkerOptions options = MarkerOptions.newInstance(); options.setIcon(icon); for (int i = 0; i < 10; i++) { LatLng point = LatLng.newInstance(southWest.getLatitude() + latSpan * Math.random(), southWest.getLongitude() + lngSpan * Math.random()); map.addOverlay(new Marker(point, options)); } }
From source file:com.google.gwt.maps.sample.hellomaps.client.MapEventDemo.java
License:Apache License
private void computeAtlantaTriangle() { LatLngBounds bounds = map.getBounds(); LatLng center = map.getCenter();//from ww w .ja v a 2 s .com LatLng ne = bounds.getNorthEast(); LatLng sw = bounds.getSouthWest(); GWT.log("ne=" + ne + ", sw=" + sw, null); double vertDelta = ne.getLatitude() - sw.getLatitude(); double horizDelta = ne.getLongitude() - sw.getLongitude(); double vertGrid = vertDelta / 4.0; double horizGrid = horizDelta / 8.0; // A triangle pointing north to the west of the center of the map. ATLANTA_TRIANGLE1[0] = LatLng.newInstance(center.getLatitude() + vertGrid, center.getLongitude() - 2 * horizGrid); ATLANTA_TRIANGLE1[1] = LatLng.newInstance(center.getLatitude() - vertGrid, center.getLongitude() - 3 * horizGrid); ATLANTA_TRIANGLE1[2] = LatLng.newInstance(center.getLatitude() - vertGrid, center.getLongitude() - horizGrid); ATLANTA_TRIANGLE1[3] = ATLANTA_TRIANGLE1[0]; GWT.log("1[0] = " + ATLANTA_TRIANGLE1[0], null); GWT.log("1[1] = " + ATLANTA_TRIANGLE1[1], null); GWT.log("1[2] = " + ATLANTA_TRIANGLE1[2], null); GWT.log("1[3] = " + ATLANTA_TRIANGLE1[3], null); // A triangle pointing south to the east of the center of the map. ATLANTA_TRIANGLE2[0] = LatLng.newInstance(center.getLatitude() - vertGrid, center.getLongitude() + 2 * horizGrid); ATLANTA_TRIANGLE2[1] = LatLng.newInstance(center.getLatitude() + vertGrid, center.getLongitude() + 3 * horizGrid); ATLANTA_TRIANGLE2[2] = LatLng.newInstance(center.getLatitude() + vertGrid, center.getLongitude() + horizGrid); ATLANTA_TRIANGLE2[3] = ATLANTA_TRIANGLE2[0]; GWT.log("2[0] = " + ATLANTA_TRIANGLE2[0], null); GWT.log("2[1] = " + ATLANTA_TRIANGLE2[1], null); GWT.log("2[2] = " + ATLANTA_TRIANGLE2[2], null); GWT.log("2[3] = " + ATLANTA_TRIANGLE2[3], null); }
From source file:com.google.gwt.maps.sample.hellomaps.client.MarkerInfoWindowDemo.java
License:Apache License
@Override public void onShow() { map.clearOverlays();/*w w w . java2s. co m*/ // Add 10 markers to the map at random locations LatLngBounds bounds = map.getBounds(); LatLng southWest = bounds.getSouthWest(); LatLng northEast = bounds.getNorthEast(); double lngSpan = northEast.getLongitude() - southWest.getLongitude(); double latSpan = northEast.getLatitude() - southWest.getLatitude(); for (int i = 0; i < 10; i++) { LatLng point = LatLng.newInstance(southWest.getLatitude() + latSpan * Math.random(), southWest.getLongitude() + lngSpan * Math.random()); map.addOverlay(createMarker(point, i + 1)); } }
From source file:com.google.gwt.maps.sample.hellomaps.client.OverlayDemo.java
License:Apache License
private void displayOverlay() { map.clearOverlays();//w ww. j a va2 s . c o 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:es.upm.fi.dia.oeg.map4rdf.share.GoogleMapsAdapters.java
License:Open Source License
public static BoundingBox getBoundingBox(LatLngBounds bonds) { return new BoundingBoxBean(getTwoDimentionalCoordinate(bonds.getSouthWest()), getTwoDimentionalCoordinate(bonds.getNorthEast())); }
From source file:org.maps.client.TRIFacilitiesLayer.java
License:Apache License
@Override protected void refreshMarkers(LatLngBounds bounds, final IRefreshMarkersCallback callback) { if (getMap().getZoomLevel() < getStartZoomLevel()) { List<Marker> newMarkers = new ArrayList<Marker>(); callback.onRefresh(newMarkers);/*from w ww. j a va 2 s. com*/ return; } setCurrentZoomLevel(getMap().getZoomLevel()); AsyncCallback<List<ITRIFacility>> serviceCallback = new AsyncCallback<List<ITRIFacility>>() { public void onFailure(Throwable caught) { callback.onError(caught); } public void onSuccess(List<ITRIFacility> result) { for (ITRIFacility facility : result) { MarkerOptions options = MarkerOptions.newInstance(); options.setTitle(facility.getFacilityName()); if (facility.getNumberOfFacilities() > 1) { String url = "images/cluster.png"; Icon icon = Icon.newInstance(url); options.setIcon(icon); } options.setDraggable(false); LatLng location = LatLng.newInstance(facility.getLatitude(), facility.getLongitude()); Marker marker = new Marker(location, options); if (facility.getNumberOfFacilities() > 1) { marker.addMarkerClickHandler(getClusterClickHandler()); } else { marker.addMarkerClickHandler(getFacilityClickHandler()); } register(marker, facility); } callback.onRefresh(getMarkers()); } }; double swLat = bounds.getSouthWest().getLatitude(); double swLng = bounds.getSouthWest().getLongitude(); double neLat = bounds.getNorthEast().getLatitude(); double neLng = bounds.getNorthEast().getLongitude(); service.get(swLat, swLng, neLat, neLng, serviceCallback); }
From source file:org.onebusaway.webapp.gwt.oba_library.view.PatchMarker.java
License:Apache License
private static LatLng getNorthWestCorner(LatLngBounds bounds) { LatLng ne = bounds.getNorthEast(); LatLng sw = bounds.getSouthWest();/* w w w . j a v a 2 s . c o m*/ return LatLng.newInstance(ne.getLatitude(), sw.getLongitude()); }