Example usage for com.google.gwt.maps.client.maptypes ImageMapTypeOptions setMinZoom

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

Introduction

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

Prototype

public final native void setMinZoom(int minZoom) ;

Source Link

Document

sets The minimum zoom level for the map when displaying this MapType.

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);//from  w w w.jav 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);
    opts.setMaxZoom(12);/*from  w ww  .ja v a2 s  .c  om*/
    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  ww . j av a  2  s  .c om*/
 * '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:pl.itrack.client.local.services.maps.TricitySchemaService.java

License:Apache License

private ImageMapType getCitySchemaMapType() {
    ImageMapTypeOptions opts = ImageMapTypeOptions.newInstance();
    opts.setMinZoom(ZOOM_MIN);
    opts.setMaxZoom(ZOOM_MAX);/*from w  w w. ja  v a2  s . c  o  m*/
    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);
}