Example usage for com.google.gwt.maps.client.maptypes TileUrlCallBack TileUrlCallBack

List of usage examples for com.google.gwt.maps.client.maptypes TileUrlCallBack TileUrlCallBack

Introduction

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

Prototype

TileUrlCallBack

Source Link

Usage

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);/*w w w . j av a  2 s  .c o  m*/
    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  .  j a  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.OpenStreetMapLayerWidget.java

License:Apache License

/**
 * Example from <a href=/*from w w  w. ja  v  a2 s .com*/
 * '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:org.rebioma.client.maps.EnvLayer.java

License:Apache License

public static EnvLayer newInstance(AscData data) {
    final EnvLayer envLayer = new EnvLayer();
    envLayer.data = data;//  w  ww.  j a  va 2s.c o m
    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;
}