List of usage examples for com.google.gwt.maps.client.base Point getX
public final native double getX() ;
From source file:com.google.gwt.maps.testing.client.maps.ImageMapTypeWidget.java
License:Apache License
private ImageMapType getMoonMapType() { ImageMapTypeOptions opts = ImageMapTypeOptions.newInstance(); opts.setMaxZoom(9);/*from w w w. j a v a 2 s .c om*/ opts.setMinZoom(0); opts.setName(LUNAR_NAME); opts.setTileSize(Size.newInstance(256d, 256d)); opts.setTileUrl(new TileUrlCallBack() { @Override public String getTileUrl(Point point, int zoomLevel) { Point normalizedCoord = getNormalizedCoord(point, zoomLevel); if (normalizedCoord == null) { return null; } double bound = Math.pow(2, zoomLevel); return "http://mw1.google.com/mw-planetary/lunar/lunarmaps_v1/clem_bw" + "/" + zoomLevel + "/" + (int) normalizedCoord.getX() + "/" + (int) (bound - normalizedCoord.getY() - 1) + ".jpg"; } }); return ImageMapType.newInstance(opts); }
From source file:com.google.gwt.maps.testing.client.maps.ImageMapTypeWidget.java
License:Apache License
private ImageMapType getMarsMapType() { ImageMapTypeOptions opts = ImageMapTypeOptions.newInstance(); opts.setTileSize(Size.newInstance(256d, 256d)); opts.setMinZoom(0);// w w w . ja v a 2 s . c om opts.setMaxZoom(12); opts.setName(MARTIAN_NAME); opts.setTileUrl(new TileUrlCallBack() { @Override public String getTileUrl(Point point, int zoomLevel) { double bound = Math.pow(2, zoomLevel); double x = point.getX(); double y = point.getY(); // don't repeat across y-axis (vertically) if (y < 0 || y >= bound) { return null; } // repeat across x-axis if (x < 0 || x >= bound) { x = (x % bound + bound) % bound; } String qstr = "t"; for (int z = 0; z < zoomLevel; z++) { bound = bound / 2; if (y < bound) { if (x < bound) { qstr += "q"; } else { qstr += "r"; x -= bound; } } else { if (x < bound) { qstr += "t"; y -= bound; } else { qstr += "s"; x -= bound; y -= bound; } } } return "http://mw1.google.com/mw-planetary/mars/infrared/" + qstr + ".jpg"; } }); return ImageMapType.newInstance(opts); }
From source file:com.google.gwt.maps.testing.client.maps.ImageMapTypeWidget.java
License:Apache License
public final static Point getNormalizedCoord(Point coord, int zoom) { double y = coord.getY(); double x = coord.getX(); // tile range in one direction range is dependent on zoom level // 0 = 1 tile, 1 = 2 tiles, 2 = 4 tiles, 3 = 8 tiles, etc double tileRange = 1 << zoom; // don't repeat across y-axis (vertically) if (y < 0 || y >= tileRange) { return null; }/*w w w. ja v a 2 s . c o m*/ // repeat across x-axis if (x < 0 || x >= tileRange) { x = (x % tileRange + tileRange) % tileRange; } return Point.newInstance(x, y); }
From source file:com.google.gwt.maps.testing.client.maps.OpenStreetMapLayerWidget.java
License:Apache License
/** * Example from <a href=//from w w w .j a v a2 s . c o m * 'https://github.com/branflake2267/GWT-Maps-V3-Api/issues/125'>GitHub * Issue</a> * * @return */ private ImageMapType getOsmMapType() { ImageMapTypeOptions opts = ImageMapTypeOptions.newInstance(); opts.setMaxZoom(20); opts.setMinZoom(1); opts.setName("OpenStreetMap"); // this is where the magic happens :) opts.setTileSize(Size.newInstance(256, 256)); opts.setTileUrl(new TileUrlCallBack() { public String getTileUrl(Point point, int zoom) { return "http://tile.openstreetmap.org/" + zoom + "/" + ((int) point.getX()) + "/" + ((int) point.getY()) + ".png"; } }); return ImageMapType.newInstance(opts); }
From source file:com.google.gwt.maps.testing.client.maps.OverlayViewMapWidget.java
License:Apache License
private void drawOverlay_Generic_OverlayView() { OverlayViewOnDrawHandler onDrawHandler = new OverlayViewOnDrawHandler() { @Override/*from w w w. j a v a2 s .co m*/ public void onDraw(OverlayViewMethods methods) { MapCanvasProjection projection = methods.getProjection(); LatLng sw = LatLng.newInstance(40.710216, -74.213393); Point p = projection.fromLatLngToDivPixel(sw); htmlOverlayMessage.getElement().getStyle().setPosition(Position.ABSOLUTE); htmlOverlayMessage.getElement().getStyle().setLeft(p.getX(), Unit.PX); htmlOverlayMessage.getElement().getStyle().setTop(p.getY(), Unit.PX); String message = "OverlayView draw() called... the projection world width is " + projection.getWorldWidth(); htmlOverlayMessage.clear(); htmlOverlayMessage.add(new HTML(message)); System.out.println(message); } }; OverlayViewOnAddHandler onAddHandler = new OverlayViewOnAddHandler() { @Override public void onAdd(OverlayViewMethods methods) { MapCanvasProjection projection = methods.getProjection(); String message = "OverlayView add() called... the projection world width is " + projection.getWorldWidth(); System.out.println(message); methods.getPanes().getFloatPane().appendChild(htmlOverlayMessage.getElement()); } }; OverlayViewOnRemoveHandler onRemoveHandler = new OverlayViewOnRemoveHandler() { @Override public void onRemove(OverlayViewMethods methods) { String message = "OverlayView remove() called..."; System.out.println(message); // remove existing nodes htmlOverlayMessage.getElement().removeFromParent(); } }; customOverlayView = OverlayView.newInstance(mapWidget, onDrawHandler, onAddHandler, onRemoveHandler); }
From source file:com.mashery.examples.api.client.weatherbug.WeatherBugOverlayView.java
License:Open Source License
@Override public void draw() { HasLatLngBounds bounds = getMap().getBounds(); HasMapCanvasProjection ovrPrj = getProjection(); HasPoint ovrNE = ovrPrj.fromLatLngToDivPixel(bounds.getNorthEast()); HasPoint ovrSW = ovrPrj.fromLatLngToDivPixel(bounds.getSouthWest()); div.getStyle().setLeft(ovrSW.getX(), Unit.PX); div.getStyle().setTop(ovrNE.getY(), Unit.PX); div.getStyle().setWidth(ovrNE.getX() - ovrSW.getX(), Unit.PX); div.getStyle().setHeight(ovrSW.getY() - ovrNE.getY(), Unit.PX); String endpoint = WEATHERBUG_ENDPOINT.replace("${layerType}", layerType.getPath()); HashSet<TileKey> usedTiles = new HashSet<TileKey>(); int zoom = getMap().getZoom(); double scale = Math.pow(2d, zoom); HasProjection prj = getMap().getProjection(); LatLng nwLatLng = new LatLng(bounds.getNorthEast().getLatitude(), bounds.getSouthWest().getLongitude()); HasPoint nwRaw = prj.fromLatLngToPoint(nwLatLng); LatLng seLatLng = new LatLng(bounds.getSouthWest().getLatitude(), bounds.getNorthEast().getLongitude()); HasPoint seRaw = prj.fromLatLngToPoint(seLatLng); Point nw = new Point(Math.floor(nwRaw.getX() * scale), Math.floor(nwRaw.getY() * scale)); Point se = new Point(Math.floor(seRaw.getX() * scale), Math.floor(seRaw.getY() * scale)); double offsetX = nw.getX() % 256d; double offsetY = nw.getY() % 256d; Point startPoint = new Point(nw.getX() - offsetX, nw.getY() - offsetY); while (startPoint.getY() < se.getY()) { Point p = new Point(startPoint.getX(), startPoint.getY()); startPoint = new Point(startPoint.getX(), startPoint.getY() + 256); while (p.getX() < se.getX()) { int tx = (int) p.getX() / 256; int ty = (int) p.getY() / 256; TileKey tileKey = new TileKey(tx, ty, zoom); usedTiles.add(tileKey);/*from ww w .ja v a 2 s. co m*/ ImageElement img = tiles.remove(tileKey); if (img == null) { img = Document.get().createImageElement(); img.getStyle().setBorderStyle(BorderStyle.NONE); img.getStyle().setBorderWidth(0d, Unit.PX); img.getStyle().setPosition(Position.ABSOLUTE); StringBuilder buf = new StringBuilder(endpoint); buf.append("&tx=").append(tx); buf.append("&ty=").append(ty); buf.append("&zm=").append(zoom); img.setSrc(buf.toString()); div.appendChild(img); } else { img.getStyle().setVisibility(Visibility.VISIBLE); } img.getStyle().setLeft(p.getX() - nw.getX(), Unit.PX); img.getStyle().setTop(p.getY() - nw.getY(), Unit.PX); img.getStyle().setWidth(256d, Unit.PX); img.getStyle().setHeight(256d, Unit.PX); tiles.put(tileKey, img); p = new Point(p.getX() + 256, p.getY()); } } for (Iterator<Map.Entry<TileKey, ImageElement>> i = tiles.entrySet().iterator(); i.hasNext();) { Map.Entry<TileKey, ImageElement> entry = i.next(); if (!usedTiles.remove(entry.getKey())) { if (tiles.size() > TILE_CACHE_SIZE) { i.remove(); entry.getValue().removeFromParent(); } else { entry.getValue().getStyle().setVisibility(Visibility.HIDDEN); } } } }
From source file:org.rebioma.client.maps.EnvLayer.java
License:Apache License
public static EnvLayer newInstance(AscData data) { final EnvLayer envLayer = new EnvLayer(); envLayer.data = data;/* w w w. j a va2 s . com*/ envLayer.imageMapTypeOptions.setTileSize(Size.newInstance(256, 256)); envLayer.imageMapTypeOptions.setOpacity(0.5); //envLayer.setOpacity(opacity); envLayer.baseUrl = GWT.getModuleBaseURL() + "ascOverlay?f=" + data.getFileName(); envLayer.imageMapTypeOptions.setTileUrl(new TileUrlCallBack() { @Override public String getTileUrl(Point point, int zoomLevel) { String tileUrl = envLayer.baseUrl; tileUrl += "&x=" + new Double(Math.rint(point.getX())).intValue(); tileUrl += "&y=" + new Double(Math.rint(point.getY())).intValue(); tileUrl += "&z=" + zoomLevel; return tileUrl; } }); return envLayer; }
From source file:pl.itrack.client.local.services.maps.TricitySchemaService.java
License:Apache License
private ImageMapType getCitySchemaMapType() { ImageMapTypeOptions opts = ImageMapTypeOptions.newInstance(); opts.setMinZoom(ZOOM_MIN);/*from ww w . ja v a 2 s. co m*/ opts.setMaxZoom(ZOOM_MAX); opts.setName(MAP_TYPE_ID); opts.setTileSize(Size.newInstance(TILE_SIZE, TILE_SIZE)); opts.setTileUrl((point, zoomLevel) -> { Point normalizedCoord = getNormalizedCoords(point, zoomLevel); if (normalizedCoord == null) { return null; } return TILE_IMAGES_PATH + PATH_SEPARATOR + (zoomLevel - 2) + PATH_SEPARATOR + +(zoomLevel - 2) + TILE_IMAGES_FILE_NAME_SEPARATOR + (int) normalizedCoord.getY() + TILE_IMAGES_FILE_NAME_SEPARATOR + (int) normalizedCoord.getX() + FILE_EXTENSION_SEPARATOR + TILE_IMAGES_FILE_EXTENSION; }); return ImageMapType.newInstance(opts); }
From source file:pl.itrack.client.local.services.maps.TricitySchemaService.java
License:Apache License
private static Point getNormalizedCoords(Point coords, int zoom) { double x = coords.getX(); double y = coords.getY(); double currentTileRange = BASE_TILE_RANGE << (zoom - 2); // repeat horizontal if (x < 0 || x >= currentTileRange) { //x = (x % currentTileRange + currentTileRange) % currentTileRange; return null; }/*from w w w . j av a 2 s . c o m*/ // repeat vertical if (y < 0 || y >= currentTileRange) { //y = (y % currentTileRange + currentTileRange) % currentTileRange; return null; } return Point.newInstance(x, y); }