Example usage for com.google.gwt.maps.client.base Size newInstance

List of usage examples for com.google.gwt.maps.client.base Size newInstance

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.base Size newInstance.

Prototype

public final static Size newInstance(double width, double height) 

Source Link

Document

creates Two-dimensional size, where width is the distance on the x-axis, and height is the distance on the y-axis.

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 ava2 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  va  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  www.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.StreetViewCustomMapWidget.java

License:Apache License

private void drawStreeView() {

    final LatLng position = LatLng.newInstance(21.259758694819777, -157.811758518219);

    StreetViewPov pov = StreetViewPov.newInstance();
    pov.setHeading(0);//from   w w  w. j ava 2  s  .  c o  m
    pov.setZoom(0);
    pov.setPitch(0);

    StreetViewPanoramaOptions options = StreetViewPanoramaOptions.newInstance();
    options.setPosition(position);
    options.setStreeViewPov(pov);
    options.setVisible(true);

    options.setPanoProvider(new StreetViewPanoramaProvider() {
        @Override
        public StreetViewPanoramaData getPanoData(String pano, int zoom, int tileX, int tileY) {

            StreetViewLocation location = StreetViewLocation.newInstance();
            location.setDescription("Diamond Head Lookout");
            location.setLatLng(position);
            location.setPano("diamondheadhike");

            Size tileSize = Size.newInstance(300d, 300d);
            Size worldSize = Size.newInstance(1708d, 400d);

            StreetViewTileData tiles = StreetViewTileData.newInstance();
            tiles.setCenterHeading(0);
            tiles.setTileSize(tileSize);
            tiles.setWorldSize(worldSize);
            tiles.getTileUrl(pano, zoom, tileX, tileY, new TileUrlHandler() {
                @Override
                public String getTileUrl(String pano, int zoom, int tileX, int tileY) {
                    zoom = 0; // TODO make a better tiled pano for testing
                    String url = "http://gonevertical-hr.appspot.com/serve?pano=99330&z=" + zoom + "&y=" + tileY
                            + "&x=" + tileX;
                    GWT.log("Got StreetView Tile from URL: " + url);
                    return url;
                }
            });

            StreetViewPanoramaData data = StreetViewPanoramaData.newInstance();
            data.setCopyright("Brandon Donnelson");
            data.setLocation(location);
            data.setTileData(tiles);

            return data;
        }
    });

    StreetViewPanoramaWidget wStreet = new StreetViewPanoramaWidget(options);
    pWidget.add(wStreet);
    wStreet.setSize("750px", "500px");

    wStreet.setPano("diamondheadhike");

}

From source file:gov.nist.spectrumbrowser.client.SensorGroupMarker.java

License:Open Source License

private SensorGroupMarker(double lat, double lon) {
    this.lat = lat;
    this.lon = lon;
    this.position = LatLng.newInstance(lat, lon);

    String iconPath = SpectrumBrowser.getIconsPath() + "mm_20_red.png";
    logger.finer("lon = " + lon + " lat = " + lat + " iconPath = " + iconPath);
    MarkerImage notSelectedIcon = MarkerImage.newInstance(iconPath);

    notSelectedIcon.setSize(Size.newInstance(12, 20));
    notSelectedIcon.setAnchor(Point.newInstance(6, 20));
    MarkerOptions notSelectedMarkerOptions = MarkerOptions.newInstance();
    notSelectedMarkerOptions.setIcon(notSelectedIcon);
    notSelectedMarkerOptions.setClickable(true);
    notSelectedMarker = Marker.newInstance(notSelectedMarkerOptions);

    // Attach marker to the map.

    notSelectedMarker.addMouseOverHandler(new NotSelectedMarkerMouseOverMapHandler());
    notSelectedMarker.addMouseOutMoveHandler(new NotSelectedMarkerMouseOutMapHandler());
    notSelectedMarker.addMouseDownHandler(new NotSelectedMarkerMouseDownMapHandler());
    notSelectedMarker.setPosition(position);
    notSelectedMarker.setVisible(true);//ww  w  . j ava  2  s  .c o m
    notSelectedMarker.setZindex(1);

    // Create icons for the selected marker.
    iconPath = SpectrumBrowser.getIconsPath() + "mm_20_yellow.png";
    MarkerImage selectedIcon = MarkerImage.newInstance(iconPath);
    selectedIcon.setSize(Size.newInstance(12, 20));
    selectedIcon.setAnchor(Point.newInstance(6, 20));
    // create marker options for the selected maker.
    MarkerOptions selectedMarkerOptions = MarkerOptions.newInstance();
    selectedMarkerOptions.setIcon(iconPath);
    selectedMarkerOptions.setClickable(true);

    // Create and attach the selected marker.
    selectedMarker = Marker.newInstance(selectedMarkerOptions);
    selectedMarker.setPosition(position);
    selectedMarker.setVisible(true);
    selectedMarker.setZindex(0);

}

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;/*from  w ww.ja  va 2s . c  om*/
    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  va2  s.com*/
    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);
}