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

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

Introduction

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

Prototype

public final static Point newInstance(double x, double y) 

Source Link

Document

creates A point on a two-dimensional plane.

Usage

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;
    }//from w  w w  .ja  va  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: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);// w  w  w  .  j  a va  2s  . com
    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:gov.wa.wsdot.mobile.client.activities.ferries.vesselwatch.VesselWatchMapViewGwtImpl.java

License:Open Source License

@Override
public void addMapMarker(Position position) {
    if (myLocationMarker != null) {
        myLocationMarker.setMap((MapWidget) null);
    }/* w ww. j a  v a 2  s  . c  o  m*/

    if (myLocationError != null) {
        myLocationError.setMap(null);
    }

    LatLng center = LatLng.newInstance(position.getCoordinates().getLatitude(),
            position.getCoordinates().getLongitude());
    MarkerOptions options = MarkerOptions.newInstance();
    options.setPosition(center);
    MarkerImage icon = MarkerImage.newInstance(AppBundle.INSTANCE.myLocationPNG().getSafeUri().asString());
    icon.setAnchor(Point.newInstance(11, 11));
    options.setOptimized(true);
    options.setIcon(icon);
    myLocationMarker = Marker.newInstance(options);
    myLocationMarker.setMap(mapWidget);

    // create a circle the size of the error
    CircleOptions circleOptions = CircleOptions.newInstance();
    circleOptions.setFillOpacity(0.1);
    circleOptions.setFillColor("#1a75ff");
    circleOptions.setStrokeOpacity(0.12);
    circleOptions.setStrokeWeight(1);
    circleOptions.setStrokeColor("#1a75ff");
    myLocationError = Circle.newInstance(circleOptions);
    myLocationError.setCenter(center);
    myLocationError.setRadius(position.getCoordinates().getAccuracy());
    myLocationError.setMap(mapWidget);
}

From source file:gov.wa.wsdot.mobile.client.activities.trafficmap.TrafficMapViewGwtImpl.java

License:Open Source License

@Override
public void addMapMarker(Position position) {

    if (myLocationMarker != null) {
        myLocationMarker.setMap((MapWidget) null);
    }//from  www .j  a  v a2 s .c om

    if (myLocationError != null) {
        myLocationError.setMap(null);
    }

    LatLng center = LatLng.newInstance(position.getCoordinates().getLatitude(),
            position.getCoordinates().getLongitude());
    MarkerOptions options = MarkerOptions.newInstance();
    options.setPosition(center);
    MarkerImage icon = MarkerImage.newInstance(AppBundle.INSTANCE.myLocationPNG().getSafeUri().asString());
    icon.setAnchor(Point.newInstance(11, 11));
    options.setOptimized(true);
    options.setIcon(icon);
    myLocationMarker = Marker.newInstance(options);
    myLocationMarker.setMap(mapWidget);

    // create a circle the size of the error
    CircleOptions circleOptions = CircleOptions.newInstance();
    circleOptions.setFillOpacity(0.1);
    circleOptions.setFillColor("#1a75ff");
    circleOptions.setStrokeOpacity(0.12);
    circleOptions.setStrokeWeight(1);
    circleOptions.setStrokeColor("#1a75ff");
    myLocationError = Circle.newInstance(circleOptions);
    myLocationError.setCenter(center);
    myLocationError.setRadius(position.getCoordinates().getAccuracy());
    myLocationError.setMap(mapWidget);

}

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;
    }// w  w w .  j  av a  2 s. com

    // repeat vertical
    if (y < 0 || y >= currentTileRange) {
        //y = (y % currentTileRange + currentTileRange) % currentTileRange;
        return null;
    }

    return Point.newInstance(x, y);
}