Example usage for com.google.gwt.maps.client.overlay MarkerOptions newInstance

List of usage examples for com.google.gwt.maps.client.overlay MarkerOptions newInstance

Introduction

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

Prototype

public static MarkerOptions newInstance() 

Source Link

Usage

From source file:org.sigmah.client.page.entry.editor.MapFieldSet.java

License:Open Source License

private void createMarker(LatLng latlng) {
    MarkerOptions options = MarkerOptions.newInstance();
    options.setDraggable(true);//w  ww . j  a va  2s .com

    marker = new Marker(latlng, options);

    marker.addMarkerDragEndHandler(new MarkerDragEndHandler() {
        public void onDragEnd(MarkerDragEndEvent event) {

            LatLng latlng = marker.getLatLng();
            presenter.onMarkerMoved(latlng.getLatitude(), latlng.getLongitude());
        }
    });

    map.addOverlay(marker);
}

From source file:org.sigmah.client.page.entry.SiteMap.java

License:Open Source License

public void highlightSite(int siteId, boolean panTo) {
    Marker marker = sites.get(siteId);// w  w w .  j  ava2 s  .  c  om
    if (marker != null) {

        // we can't change the icon ( I don't think )
        // so we'll bring in a ringer for the selected site

        if (highlitMarker == null) {
            GcIconFactory iconFactory = new GcIconFactory();
            iconFactory.primaryColor = "#0000FF";
            MarkerOptions opts = MarkerOptions.newInstance();
            opts.setIcon(iconFactory.createMarkerIcon());
            highlitMarker = new Marker(marker.getLatLng(), opts);
            map.addOverlay(highlitMarker);
        } else {
            // make sure this marker is on top
            map.removeOverlay(highlitMarker);
            highlitMarker.setLatLng(marker.getLatLng());
            map.addOverlay(highlitMarker);
        }

        if (currentHighlightedMarker != null) {
            currentHighlightedMarker.setVisible(true);
        }
        currentHighlightedMarker = marker;
        currentHighlightedMarker.setVisible(false);

        if (!map.getBounds().containsLatLng(marker.getLatLng())) {
            map.panTo(marker.getLatLng());
        }
    } else {
        // no coords, un highlight existing marker
        if (currentHighlightedMarker != null) {
            currentHighlightedMarker.setVisible(true);
        }
        if (highlitMarker != null) {
            map.removeOverlay(highlitMarker);
            highlitMarker = null;
        }
    }
}

From source file:org.sigmah.client.page.map.MapPreview.java

License:Open Source License

/**
 * Updates the size of the map and adds Overlays to reflect the content
 * of the current/*from   w  ww. ja  v a2 s  .  com*/
 */
private void updateMapToContent() {

    map.setWidth(element.getWidth() + "px");
    map.setHeight(element.getHeight() + "px");

    Log.debug("MapPreview: Received content, extents are = " + content.getExtents().toString());

    zoomToBounds(llBoundsForExtents(content.getExtents()));

    layout();

    map.checkResizeAndCenter();

    // TODO: i18n
    status.setStatus(content.getUnmappedSites().size() + " " + I18N.CONSTANTS.siteLackCoordiantes(), null);

    GcIconFactory iconFactory = new GcIconFactory();
    iconFactory.primaryColor = "#0000FF";

    for (MapMarker marker : content.getMarkers()) {
        Icon icon = IconFactory.createIcon(marker);
        LatLng latLng = LatLng.newInstance(marker.getLat(), marker.getLng());

        MarkerOptions options = MarkerOptions.newInstance();
        options.setIcon(icon);

        Marker overlay = new Marker(latLng, options);

        map.addOverlay(overlay);
        overlays.add(overlay);
    }
}

From source file:org.sigmah.client.ui.widget.map.GoogleWorldMap.java

License:Open Source License

@Override
protected Marker createNativePin(Pin pin) {
    final MarkerOptions options = MarkerOptions.newInstance();

    if (pin.getTitle() != null) {
        options.setTitle(pin.getTitle());
    }/*from ww w. j  av a2 s  . c om*/

    options.setDraggable(pin.isDraggable());

    if (pin.getImageURL() != null) {
        final Icon icon = Icon.newInstance(pin.getImageURL());
        icon.setIconSize(Size.newInstance(pin.getImageWidth(), pin.getImageHeight()));
        icon.setIconAnchor(Point.newInstance(
                // Horizontal center
                pin.getImageWidth() / 2,
                // Bottom
                pin.getImageHeight()));
        options.setIcon(icon);
    }

    return new Marker(LatLng.newInstance(pin.getLatitude(), pin.getLongitude()), options);
}