Example usage for com.google.gwt.maps.client.overlays MarkerImage setAnchor

List of usage examples for com.google.gwt.maps.client.overlays MarkerImage setAnchor

Introduction

In this page you can find the example usage for com.google.gwt.maps.client.overlays MarkerImage setAnchor.

Prototype

public final native void setAnchor(Point anchor) ;

Source Link

Document

sets The position at which to anchor an image in correspondance to the location of the marker on the map.

Usage

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);//from   www  .  j  a  v a 2  s . co 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: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);
    }//from  ww w  .j  av a 2  s .  co  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   w w  w  .j a  v  a2  s.com*/

    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);

}