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

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

Introduction

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

Prototype

public final native void setIconSize(Size size) ;

Source Link

Document

Sets the pixel size of the foreground image of the 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 . j a  v a2 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.onebusaway.webapp.gwt.common.resources.map.StopIconFactory.java

License:Apache License

/*****
 * Private Methods//  w w  w  . jav a 2s .  co  m
 ****/

private static Icon getRouteIcon(String url) {
    Icon icon = Icon.newInstance();
    icon.setImageURL(url);
    icon.setIconSize(Size.newInstance(20, 34));
    icon.setIconAnchor(Point.newInstance(10, 34));
    return icon;
}

From source file:org.onebusaway.webapp.gwt.oba_application.view.ActiveResultPresenter.java

License:Apache License

private Icon getStar30Marker() {
    OneBusAwayStandardResources resources = OneBusAwayStandardResources.INSTANCE;
    ImageResource r = resources.getStar30();
    Icon icon = Icon.newInstance(r.getURL());
    icon.setIconSize(Size.newInstance(30, 28));
    icon.setIconAnchor(Point.newInstance(15, 14));
    return icon;/*from   w  ww.  ja  va  2  s  .co  m*/
}

From source file:org.onebusaway.webapp.gwt.oba_application.view.ActiveResultPresenter.java

License:Apache License

private Icon getStar20Marker() {
    OneBusAwayStandardResources resources = OneBusAwayStandardResources.INSTANCE;
    ImageResource r = resources.getStar20();
    Icon icon = Icon.newInstance(r.getURL());
    icon.setIconSize(Size.newInstance(20, 19));
    icon.setIconAnchor(Point.newInstance(10, 10));
    return icon;/*  ww  w.  j  a v a  2 s.  c  o  m*/
}

From source file:org.onebusaway.webapp.gwt.oba_application.view.ActiveResultPresenter.java

License:Apache License

private Icon getStar15Marker() {
    OneBusAwayStandardResources resources = OneBusAwayStandardResources.INSTANCE;
    ImageResource r = resources.getStar15();
    Icon icon = Icon.newInstance(r.getURL());
    icon.setIconSize(Size.newInstance(15, 14));
    icon.setIconAnchor(Point.newInstance(8, 7));
    return icon;//from w  w w. j a  v a  2s.co m
}

From source file:org.onebusaway.webapp.gwt.oba_application.view.ResultsTablePresenter.java

License:Apache License

private Marker getMarker(int index, LocalSearchResult entry) {

    ImageResource resource = getMarkerResource(index);
    Icon icon = Icon.newInstance(resource.getURL());
    icon.setIconSize(Size.newInstance(24, 31));
    icon.setIconAnchor(Point.newInstance(12, 31));
    MarkerOptions opts = MarkerOptions.newInstance();
    opts.setClickable(true);//w  w  w .java 2s .com
    opts.setIcon(icon);
    LatLng point = LatLng.newInstance(entry.getLat(), entry.getLon());
    return new Marker(point, opts);
}

From source file:org.onebusaway.webapp.gwt.oba_application.view.SearchOriginMapPresenter.java

License:Apache License

public void handleUpdate(StateEvent event) {

    State state = event.getState();

    if (state instanceof SearchLocationUpdatedState) {

        if (_marker != null) {
            _mapOverlayManager.removeOverlay(_marker);
            _marker = null;//from  www .  ja v a2 s.  c o m
        }

        LatLng location = _queryModel.getLocation();

        if (location == null) {
            System.err.println("PROBLEM!");
            return;
        }

        MapResources resources = MapResources.INSTANCE;
        DataResource resource = resources.getImageRouteStart();
        Icon icon = Icon.newInstance();
        icon.setImageURL(resource.getUrl());
        icon.setIconSize(Size.newInstance(20, 34));
        icon.setIconAnchor(Point.newInstance(10, 34));
        MarkerOptions opts = MarkerOptions.newInstance(icon);

        _marker = new Marker(location, opts);
        _mapOverlayManager.addOverlay(_marker);
    }

}

From source file:org.opennms.features.poller.remote.gwt.client.GoogleMapsPanel.java

License:Open Source License

private Marker createMarker(final GWTMarkerState marker) {
    final Icon icon = Icon.newInstance();
    icon.setIconSize(Size.newInstance(32, 32));
    icon.setIconAnchor(Point.newInstance(16, 32));
    String markerImageURL = marker.getImageURL();
    icon.setImageURL(markerImageURL);/* w ww . j ava 2  s.c o m*/

    final MarkerOptions markerOptions = MarkerOptions.newInstance();
    markerOptions.setAutoPan(true);
    markerOptions.setClickable(true);
    markerOptions.setTitle(marker.getName());
    markerOptions.setIcon(icon);

    Marker m = new Marker(toLatLng(marker.getLatLng()), markerOptions);
    m.setVisible(marker.isVisible());
    m.addMarkerClickHandler(new DefaultMarkerClickHandler(marker));
    return m;
}

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./*from   w  w w .  ja v  a 2s. c  o  m*/
  *
  * @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;
}