List of usage examples for com.google.gwt.maps.client.geom LatLngBounds intersects
public final native boolean intersects(LatLngBounds other) ;
true if the specified rectangle intersects this rectangle. 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 w w . ja v a2 s. c om } //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"; }