List of usage examples for com.google.gwt.maps.client.geom LatLngBounds newInstance
public static native LatLngBounds newInstance(LatLng southWest, LatLng northEast) ;
From source file:com.google.gwt.maps.sample.hellomaps.client.CustomMapTypeDemo.java
License:Apache License
public CustomMapTypeDemo() { VerticalPanel vertPanel = new VerticalPanel(); vertPanel.setStyleName("hm-panel"); map = new MapWidget(LatLng.newInstance(33.7814790, -84.3880580), 13); map.setSize("500px", "450px"); CopyrightCollection myCopyright = new CopyrightCollection(""); myCopyright.addCopyright(new Copyright(1, LatLngBounds.newInstance(LatLng.newInstance(34, -81), LatLng.newInstance(36, -79)), 10, "")); TileLayer tileLayer = new TileLayer(myCopyright, 10, 18) { @Override/*from w w w . j a v a 2 s. com*/ public double getOpacity() { return 1.0; } @Override public String getTileURL(Point tile, int zoomLevel) { return "http://www.google.com/apis/maps/documentation/examples/include/tile_crosshairs.png"; } @Override public boolean isPng() { return true; } }; MapType mapType = new MapType(new TileLayer[] { tileLayer }, new MercatorProjection(20), "MyMap"); map.addMapType(mapType); map.addControl(new MapTypeControl()); vertPanel.add(map); initWidget(vertPanel); }
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 w w w . j av a 2 s . co 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;//from w w w. j a va 2 s.co 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:es.upm.fi.dia.oeg.map4rdf.share.GoogleMapsAdapters.java
License:Open Source License
public static LatLngBounds getLatLngBounds(BoundingBox boundingBox) { return LatLngBounds.newInstance(getLatLng(boundingBox.getBottomLeft()), getLatLng(boundingBox.getTopRight())); }
From source file:org.maps.client.GMapCreatorTileLayer.java
License:Apache License
@Override public String getTileURL(Point tile, int zoomLevel) { String prefix = getUrlPrefix(); String secondaryPrefix = getSecondaryPrefix(); if (zoomLevel >= getSecondaryZoomStart() && secondaryPrefix == null) { return prefix + "blank-tile.png"; } else if (zoomLevel >= getSecondaryZoomStart() && secondaryPrefix != null) { prefix = secondaryPrefix;/*from w ww . j a v a 2s.c o m*/ } //System.out.println("prefix is: " + prefix); final LatLngBounds mapBounds = LatLngBounds.newInstance(LatLng.newInstance(17.884813, -179.14734), LatLng.newInstance(71.35256, 179.77847)); double c = Math.pow(2, zoomLevel); double x = 360 / c * tile.getX() - 180; double y = 180 - 360 / c * tile.getY(); double x2 = x + 360 / c; double y2 = y - 360 / c; double lon = x; // Math.toRadians(x); //would be lon=x+lon0, but lon0=0 // degrees double lat = (2.0 * Math.atan(Math.exp(y / 180 * Math.PI)) - Math.PI / 2.0) * 180 / Math.PI; // in degrees double lon2 = x2; double lat2 = (2.0 * Math.atan(Math.exp(y2 / 180 * Math.PI)) - Math.PI / 2.0) * 180 / Math.PI; // in degrees LatLngBounds tileBounds = LatLngBounds.newInstance(LatLng.newInstance(lat2, lon), LatLng.newInstance(lat, lon2)); if (!tileBounds.intersects(mapBounds)) { return prefix + "blank-tile.png"; } ; double d = tile.getX(); double e = tile.getY(); String f = "t"; for (int g = 0; g < zoomLevel; g++) { c = c / 2; if (e < c) { if (d < c) { f = f + "q"; } else { f = f + "r"; d -= c; } } else { if (d < c) { f = f + "t"; e -= c; } else { f = f + "s"; d -= c; e -= c; } } } return prefix + f + ".png"; }
From source file:org.onebusaway.webapp.gwt.where_library.view.StopFinderWidget.java
License:Apache License
/***************************************************************************** * Public Methods//from w w w . j a va2s .co m ****************************************************************************/ public StopFinderWidget() { initWidget(_uiBinder.createAndBindUi(this)); _map.addControl(new LargeMapControl()); _map.addControl(new MapTypeControl()); _map.addControl(new ScaleControl()); _map.setScrollWheelZoomEnabled(true); // We delay initialization of the map Scheduler scheduler = Scheduler.get(); scheduler.scheduleDeferred(new ScheduledCommand() { @Override public void execute() { _map.checkResizeAndCenter(); CoordinateBounds b = _config.getBounds(); LatLng from = LatLng.newInstance(b.getMinLat(), b.getMinLon()); LatLng to = LatLng.newInstance(b.getMaxLat(), b.getMaxLon()); LatLngBounds bounds = LatLngBounds.newInstance(from, to); int zoom = _map.getBoundsZoomLevel(bounds); System.out.println(bounds + " => " + zoom); _map.setZoomLevel(zoom); _map.checkResizeAndCenter(); } }); _transitMapManager.addStopClickedHandler(new StopClickedHandler() { @Override public void handleStopClicked(StopClickedEvent event) { StopBean stop = event.getStop(); InfoWindow window = _map.getInfoWindow(); LatLng point = LatLng.newInstance(stop.getLat(), stop.getLon()); Widget widget = getStopInfoWindowWidget(stop, style); window.open(point, new InfoWindowContent(widget)); } }); }
From source file:org.opennms.features.poller.remote.gwt.client.utils.GoogleMapsUtils.java
License:Open Source License
/** * <p>toLatLngBounds</p>//from w w w .j a v a2 s . co m * * @param bounds a {@link org.opennms.features.poller.remote.gwt.client.GWTBounds} object. * @return a {@link com.google.gwt.maps.client.geom.LatLngBounds} object. */ public static LatLngBounds toLatLngBounds(GWTBounds bounds) { return LatLngBounds.newInstance(toLatLng(bounds.getSouthWestCorner()), toLatLng(bounds.getNorthEastCorner())); }
From source file:org.sigmah.client.map.BaseMapLayer.java
License:Open Source License
public static CopyrightCollection createCopyRights(BaseMap baseMap) { Copyright copyright = new Copyright(1, LatLngBounds.newInstance(LatLng.newInstance(-90, -180), LatLng.newInstance(90, 180)), 0, baseMap.getCopyright());//w w w . j av a2 s . com CopyrightCollection copyrights = new CopyrightCollection(); copyrights.addCopyright(copyright); return copyrights; }
From source file:org.sigmah.client.map.RgcTileLayer.java
License:Open Source License
public static Copyright createRgcCopyright() { return new Copyright(1, LatLngBounds.newInstance(LatLng.newInstance(-13.45599996, 12.18794184), LatLng.newInstance(5.386098154, 31.306)), 0, "Le Référentiel Géographique Commun (RGC)"); }
From source file:org.sigmah.client.page.entry.editor.MapFieldSet.java
License:Open Source License
private static LatLngBounds createLatLngBounds(BoundingBoxDTO bounds) { return LatLngBounds.newInstance(LatLng.newInstance(bounds.y1, bounds.x1), LatLng.newInstance(bounds.y2, bounds.x2)); }