Example usage for com.google.gwt.maps.client.overlay HasMarker setMap

List of usage examples for com.google.gwt.maps.client.overlay HasMarker setMap

Introduction

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

Prototype

void setMap(HasMap map);

Source Link

Document

Renders the marker on the specified map.

Usage

From source file:com.google.mobile.trippy.web.client.view.MapView.java

License:Apache License

@Override
public final void clearOverlays() {
    if (markers == null || markers.isEmpty()) {
        return;//from  w w w  .  j  av a2 s. co m
    }
    NullMap nullMap = new NullMap();
    for (HasMarker marker : markers) {
        marker.setMap(nullMap);
    }
    markers.clear();
    nullMap = null;
}

From source file:com.google.mobile.trippy.web.client.view.MapView.java

License:Apache License

/**
 * Create a new marker on the map./*w ww . j  a v  a2s  . c o  m*/
 * The marker is by default clickable and non-draggable
 */
@Override
public final HasMarker newMarker(HasLatLng position) {
    HasMarker marker = new Marker();
    marker.setPosition(position);
    marker.setMap(getMap());
    marker.setDraggable(false);
    marker.setClickable(true);
    marker.setIcon(new MarkerImage.Builder(TrippyBundle.INSTANCE.mapMarkerNormal().getURL()).build());
    if (markers == null) {
        markers = new ArrayList<HasMarker>();
    }
    markers.add(marker);
    return marker;
}

From source file:com.mashery.examples.api.client.PopupMapWidget.java

License:Open Source License

public PopupMapWidget() {
    mapPanel = new PopupPanel(true);
    mapPanel.setAutoHideOnHistoryEventsEnabled(true);
    mapPanel.setAnimationEnabled(true);/*from   www . j  a va  2s  .c  o  m*/

    MapOptions options = new MapOptions();
    options.setZoom(1);
    options.setCenter(new LatLng(0d, 0d));
    options.setMapTypeId(new MapTypeId().getRoadmap());
    options.setDraggable(true);
    options.setScrollwheel(true);
    options.setNavigationControl(true);
    options.setMapTypeControl(true);
    mapWidget = new MapWidget(options);
    mapWidget.setSize("512px", "512px");

    FlowPanel mapContainer = new FlowPanel();
    mapPanel.setWidget(mapContainer);
    mapContainer.add(mapWidget);

    Anchor clearMarkersLink = new Anchor("Clear Markers", "#");
    mapContainer.add(clearMarkersLink);
    clearMarkersLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            event.preventDefault();
            // there's no way to setMap(null) on a marker
            // instead, assign it to a dummy map
            MapWidget garbage = new MapWidget(new MapOptions());
            HasMap map = garbage.getMap();
            for (HasMarker marker : markers.values())
                marker.setMap(map);

            markers.clear();
        }
    });

    mapButton = new ToggleButton("Map");
    mapPanel.addAutoHidePartner(mapButton.getElement());
    mapButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (mapButton.isDown())
                mapPanel.showRelativeTo(mapButton);
            else
                mapPanel.hide();
        }
    });

    mapPanel.addCloseHandler(new CloseHandler<PopupPanel>() {
        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            mapButton.setDown(false);
        }
    });

    initWidget(mapButton);
}

From source file:com.mashery.examples.api.client.PopupMapWidget.java

License:Open Source License

public void show(HasMarker marker) {
    HasLatLng position = marker.getPosition();
    double lat = position == null ? 0d : position.getLatitude();
    double lng = position == null ? 0d : position.getLongitude();
    MarkerKey key = new MarkerKey(marker.getTitle(), lat, lng);
    if (!markers.containsKey(key)) {
        marker.setMap(mapWidget.getMap());
        markers.put(key, marker);//from  w  w w  . jav  a 2  s  . co  m
    }

    show(position == null ? new LatLng(lat, lng) : position);
}