Example usage for com.google.gwt.maps.client.overlay Icon setInfoWindowAnchor

List of usage examples for com.google.gwt.maps.client.overlay Icon setInfoWindowAnchor

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.overlay Icon setInfoWindowAnchor.

Prototype

public final native void setInfoWindowAnchor(Point anchor) ;

Source Link

Document

Sets the pixel coordinate relative to the top left corner of the icon image at which the info window is anchored to this icon.

Usage

From source file:com.google.gwt.maps.sample.hellomaps.client.IconDemo.java

License:Apache License

@Override
public void onShow() {
    map.clearOverlays();/*  w w w.ja  va 2  s .c o  m*/

    // Create our "tiny" marker icon
    Icon icon = Icon.newInstance("http://labs.google.com/ridefinder/images/mm_20_red.png");
    icon.setShadowURL("http://labs.google.com/ridefinder/images/mm_20_shadow.png");
    icon.setIconSize(Size.newInstance(12, 20));
    icon.setShadowSize(Size.newInstance(22, 20));
    icon.setIconAnchor(Point.newInstance(6, 20));
    icon.setInfoWindowAnchor(Point.newInstance(5, 1));

    // Add 10 markers to the map at random locations
    LatLngBounds bounds = map.getBounds();
    LatLng southWest = bounds.getSouthWest();
    LatLng northEast = bounds.getNorthEast();
    double lngSpan = northEast.getLongitude() - southWest.getLongitude();
    double latSpan = northEast.getLatitude() - southWest.getLatitude();
    MarkerOptions options = MarkerOptions.newInstance();
    options.setIcon(icon);
    for (int i = 0; i < 10; i++) {
        LatLng point = LatLng.newInstance(southWest.getLatitude() + latSpan * Math.random(),
                southWest.getLongitude() + lngSpan * Math.random());

        map.addOverlay(new Marker(point, options));
    }
}

From source file:org.onebusaway.webapp.gwt.common.resources.map.StopIconFactory.java

License:Apache License

public static Marker getStopSelectionCircle(LatLng p, boolean bigger) {
    ImageResource resource = bigger ? _r.getSelectionCircle36() : _r.getSelectionCircle30();

    Icon icon = Icon.newInstance();
    icon.setImageURL(resource.getURL());

    int w = resource.getWidth();
    int h = resource.getHeight();
    int w2 = w / 2;
    int h2 = h / 2;

    icon.setIconSize(Size.newInstance(w, h));
    icon.setIconAnchor(Point.newInstance(w2, h2));
    icon.setInfoWindowAnchor(Point.newInstance(w2, h2));

    MarkerOptions options = MarkerOptions.newInstance(icon);
    return new Marker(p, options);
}

From source file:org.sigmah.client.map.GcIconFactory.java

License:Open Source License

/**
 * Creates an icon based on the specified options
 *   Supported options are: width, height, primaryColor,
 *   strokeColor, and cornerColor.//w  w w  .ja v  a  2 s .c om
  *
  * @return Icon for GoogleMaps
 */
public Icon createMarkerIcon() {

    String baseUrl = "http://chart.apis.google.com/chart?cht=mm";
    String iconUrl = baseUrl + "&chs=" + width + "x" + height + "&chco=" + cornerColor.replace("#", "") + ","
            + primaryColor.replace("#", "") + "," + strokeColor.replace("#", "") + "&ext=.png";

    Icon icon = Icon.newInstance(iconUrl);
    icon.setIconSize(Size.newInstance(width, height));
    icon.setShadowSize(Size.newInstance((int) Math.floor(width * 1.6), height));
    icon.setIconAnchor(Point.newInstance(width / 2, height));
    icon.setInfoWindowAnchor(Point.newInstance(width / 2, (int) Math.floor(height / 12)));
    icon.setPrintImageURL(iconUrl + "&chof=gif");
    icon.setMozPrintImageURL(iconUrl + "&chf=bg,s,ECECD8" + "&chof=gif");

    iconUrl = baseUrl + "&chs=" + width + "x" + height + "&chco=" + cornerColor.replace("#", "") + ","
            + primaryColor.replace("#", "") + "," + strokeColor.replace("#", "");
    icon.setTransparentImageURL(iconUrl + "&chf=a,s,ffffff11&ext=.png");
    icon.setImageMap(new int[] { width / 2, height, (int) ((7d / 16d) * width), (int) ((5d / 8d) * height),
            (int) ((5d / 16d) * width), (int) ((7d / 16d) * height), (int) ((7d / 32d) * width),
            (int) ((5d / 16d) * height), (int) ((5d / 16d) * width), (int) ((1d / 8d) * height),
            (int) ((1d / 2d) * width), 0, (int) ((11d / 16d) * width), (int) ((1d / 8d) * height),
            (int) ((25d / 32d) * width), (int) ((5d / 16d) * height), (int) ((11d / 16d) * width),
            (int) ((7d / 16d) * height), (int) ((9d / 16d) * width), (int) ((5d / 8d) * height) });

    return icon;
}

From source file:org.sigmah.client.map.GcIconFactory.java

License:Open Source License

/**
* Creates a flat icon based on the specified options
*     Supported options are: width, height, primaryColor,
*     shadowColor, label, labelColor, labelSize, and shape..
 *
 * @return Icon object for use in GoogleMaps
*///from  ww  w.  ja  v  a  2s. c om
public Icon createFlatIcon() {
    String shapeCode = ("circle".equals(shape)) ? "it" : "itr";

    String baseUrl = "http://chart.apis.google.com/chart?cht=" + shapeCode;
    String iconUrl = baseUrl + "&chs=" + width + "x" + height + "&chco=" + primaryColor.replace("#", "") + ","
            + shadowColor.replace("#", "") + "ff,ffffff01" + "&chl=" + label + "&chx="
            + labelColor.replace("#", "") + "," + labelSize;
    Icon icon = Icon.newInstance(Icon.DEFAULT_ICON);
    icon.setImageURL(iconUrl + "&chf=bg,s,00000000" + "&ext=.png");
    icon.setIconSize(Size.newInstance(width, height));
    icon.setShadowSize(Size.newInstance(0, 0));
    icon.setIconAnchor(Point.newInstance(width / 2, height / 2));
    icon.setInfoWindowAnchor(Point.newInstance(width / 2, height / 2));
    icon.setPrintImageURL(iconUrl + "&chof=gif");
    icon.setMozPrintImageURL(iconUrl + "&chf=bg,s,ECECD8" + "&chof=gif");
    icon.setTransparentImageURL(iconUrl + "&chf=a,s,ffffff01&ext=.png");

    if (shapeCode.equals("itr")) {
        icon.setImageMap(new int[] { 0, 0, width, 0, width, height, 0, height });
    } else {
        icon.setImageMap(createCircleImageMap(width, height, 8));
    }

    return icon;
}

From source file:org.sigmah.client.map.IconFactory.java

License:Open Source License

/**
 * Creates a Google Maps icon based on an ActivityInfo MapIcon
 *
 * @author Alex Bertram//from  w  w  w  .j  a v a 2s  . c  o  m
 */
public static Icon createIconMapMarker(IconMapMarker marker) {

    MapIcon mapIcon = marker.getIcon();
    String iconUrl = "mapicons/" + mapIcon.getName() + ".png";

    Icon icon = Icon.newInstance(Icon.DEFAULT_ICON);
    icon.setImageURL(iconUrl);
    icon.setIconSize(Size.newInstance(mapIcon.getWidth(), mapIcon.getHeight()));
    icon.setShadowSize(Size.newInstance(0, 0));
    Point anchor = Point.newInstance(mapIcon.getAnchorX(), mapIcon.getAnchorY());
    icon.setIconAnchor(anchor);
    icon.setInfoWindowAnchor(anchor);
    icon.setPrintImageURL(iconUrl + "&chof=gif");
    icon.setMozPrintImageURL(iconUrl);

    return icon;
}

From source file:org.sigmah.client.map.IconFactory.java

License:Open Source License

public static Icon createBubbleMapMarker(BubbleMapMarker marker) {
    StringBuilder sb = new StringBuilder();
    sb.append("icon?t=bubble&r=").append(marker.getRadius()).append("&c=").append(marker.getColor());
    String iconUrl = sb.toString();
    int size = marker.getRadius() * 2;

    Icon icon = Icon.newInstance(Icon.DEFAULT_ICON);
    icon.setImageURL(iconUrl);//from  w  w w. j  av  a2 s  . com
    icon.setIconSize(Size.newInstance(size, size));
    icon.setShadowSize(Size.newInstance(0, 0));
    Point anchor = Point.newInstance(marker.getRadius(), marker.getRadius());
    icon.setIconAnchor(anchor);
    icon.setInfoWindowAnchor(anchor);
    icon.setPrintImageURL(iconUrl);
    icon.setMozPrintImageURL(iconUrl);

    return icon;
}

From source file:org.yocto.sample.client.ui.CurrentYoctoMarker.java

License:Open Source License

private static MarkerOptions createOptions() {
    Icon icon = Icon.newInstance("http://maps.google.com/mapfiles/marker_purple.png");
    icon.setIconSize(Size.newInstance(20, 34));
    icon.setIconAnchor(Point.newInstance(10, 34));
    icon.setInfoWindowAnchor(Point.newInstance(5, 1));
    return MarkerOptions.newInstance(icon);
}

From source file:org.yocto.sample.client.ui.MarkerFactory.java

License:Open Source License

private static MarkerOptions createOptions(String img) {
    Icon icon = Icon.newInstance(img);
    icon.setIconSize(Size.newInstance(20, 34));
    icon.setIconAnchor(Point.newInstance(10, 34));
    icon.setInfoWindowAnchor(Point.newInstance(5, 1));
    return MarkerOptions.newInstance(icon);
}