Example usage for com.google.gwt.maps.client.overlay Marker Marker

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

Introduction

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

Prototype

public Marker(LatLng point, MarkerOptions options) 

Source Link

Document

Create a new marker at the specified point using the supplied options overrides.

Usage

From source file:com.claudiushauptmann.gwt.maps.gxt.samples.client.OverlayEditor.java

License:Apache License

public void onModuleLoad() {
    // Map/* w w w .ja  va  2 s. c  om*/
    mapWidget = new MapWidget();
    mapWidget.setCenter(LatLng.newInstance(48.136559, 11.576318), 13);
    mapWidget.setWidth("100%");
    mapWidget.setHeight("100%");
    mapWidget.addControl(new LargeMapControl());
    mapWidget.setContinuousZoom(true);
    mapWidget.setScrollWheelZoomEnabled(true);
    RootPanel.get().add(mapWidget);

    // MapController
    mapGxtController = new MapGXTController(mapWidget);
    mapMenuProvider = new MapMenuProvider();
    mapGxtController.setMenuProvider(mapMenuProvider);

    // Marker
    MarkerOptions mo = MarkerOptions.newInstance();
    mo.setClickable(true);
    mo.setDraggable(true);
    Marker marker = new Marker(mapWidget.getCenter(), mo);
    mapWidget.addOverlay(marker);
    new MyMarkerEditController(mapGxtController, marker, "Marienplatz",
            "Marienplatz is a central square in the" + " city center of Munich, Germany since 1158.<br/>"
                    + " In the Middle Ages markets and tournaments were held in this"
                    + " city square. The Glockenspiel in the new city hall was inspired"
                    + " by these tournaments, and draws millions of tourists a year.");

    // Polyline
    LatLng[] llline = new LatLng[3];
    llline[0] = LatLng.newInstance(48.131955, 11.527061);
    llline[1] = LatLng.newInstance(48.11809, 11.579247);
    llline[2] = LatLng.newInstance(48.127143, 11.638298);
    PolylineOptions plo = PolylineOptions.newInstance(true, false);
    Polyline line = new Polyline(llline, "#FF0000", 2, 1.0, plo);
    mapWidget.addOverlay(line);
    new MyPolylineEditController(mapGxtController, line, "Polyline", "This is a polyline.");

    // Polygon
    LatLng[] llpolygon = new LatLng[4];
    llpolygon[0] = LatLng.newInstance(48.119809, 11.539936);
    llpolygon[1] = LatLng.newInstance(48.158185, 11.541138);
    llpolygon[2] = LatLng.newInstance(48.155894, 11.569118);
    llpolygon[3] = llpolygon[0];
    PolygonOptions pgo = PolygonOptions.newInstance(true);
    Polygon polygon = new Polygon(llpolygon, "#0000FF", 2, 1.0, "#0000FF", 0.3, pgo);
    mapWidget.addOverlay(polygon);
    new MyPolygonEditController(mapGxtController, polygon, "Polygon", "This is a polygon.");
}

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

License:Apache License

@Override
public void onShow() {
    map.clearOverlays();/*from  w  ww.ja v a2  s  .c o  m*/

    MarkerOptions options = MarkerOptions.newInstance();
    options.setDraggable(true);
    final Marker marker = new Marker(map.getCenter(), options);
    final InfoWindow info = map.getInfoWindow();

    marker.addMarkerDragEndHandler(new MarkerDragEndHandler() {
        public void onDragEnd(MarkerDragEndEvent event) {
            info.open(marker, new InfoWindowContent("Just bouncing along..."));
        }

    });

    marker.addMarkerDragStartHandler(new MarkerDragStartHandler() {
        public void onDragStart(MarkerDragStartEvent event) {
            info.setVisible(false);
        }
    });

    map.addOverlay(marker);
}

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

License:Apache License

/**
 * Creates a marker whose info window displays the letter corresponding to the
 * given index./*from w w  w.  j a va  2  s .c  o  m*/
 */
private Marker createMarker(LatLng point, int index) {
    // Create a lettered icon for this point using our icon class
    final char letter = (char) ('A' + index);
    Icon icon = Icon.newInstance(baseIcon);
    icon.setImageURL("http://www.google.com/mapfiles/marker" + letter + ".png");
    MarkerOptions options = MarkerOptions.newInstance();
    options.setIcon(icon);
    final Marker marker = new Marker(point, options);

    marker.addMarkerClickHandler(new MarkerClickHandler() {

        public void onClick(MarkerClickEvent event) {
            InfoWindow info = map.getInfoWindow();
            info.open(event.getSender(), new InfoWindowContent("Marker <b>" + letter + "</b>"));
        }

    });

    return marker;
}

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 a  2s .co 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:com.google.gwt.maps.sample.hellomaps.client.MapEventDemo.java

License:Apache License

public MapEventDemo() {
    VerticalPanel vp = new VerticalPanel();

    // Center the new map on Midtown Atlanta
    map = new MapWidget(ATLANTA, 13);
    map.setSize("500px", "300px");
    map.addControl(new SmallMapControl());
    map.addControl(new MapTypeControl());

    MarkerOptions opt = MarkerOptions.newInstance();
    opt.setDraggable(true);/*from  w  w w  . j  av  a 2 s . c  o  m*/
    marker = new Marker(ATLANTA, opt);

    Panel hp1 = createActionButtons();

    HorizontalPanel hp2 = createListenerListBox();

    // Make a spacer
    HorizontalPanel hp3 = new HorizontalPanel();
    hp3.add(new Label(" "));
    hp3.setSize("1em", "1em");

    handlerTable = new FlexTable();
    clearListenerTable();

    vp.add(map);
    vp.add(hp1);
    vp.add(hp2);
    vp.add(hp3);
    vp.add(handlerTable);

    initWidget(vp);
}

From source file:org.maps.client.TRIFacilitiesLayer.java

License:Apache License

@Override
protected void refreshMarkers(LatLngBounds bounds, final IRefreshMarkersCallback callback) {

    if (getMap().getZoomLevel() < getStartZoomLevel()) {
        List<Marker> newMarkers = new ArrayList<Marker>();
        callback.onRefresh(newMarkers);// ww w .j  a v a2  s  . c o  m
        return;
    }
    setCurrentZoomLevel(getMap().getZoomLevel());

    AsyncCallback<List<ITRIFacility>> serviceCallback = new AsyncCallback<List<ITRIFacility>>() {
        public void onFailure(Throwable caught) {
            callback.onError(caught);
        }

        public void onSuccess(List<ITRIFacility> result) {
            for (ITRIFacility facility : result) {
                MarkerOptions options = MarkerOptions.newInstance();
                options.setTitle(facility.getFacilityName());
                if (facility.getNumberOfFacilities() > 1) {
                    String url = "images/cluster.png";
                    Icon icon = Icon.newInstance(url);
                    options.setIcon(icon);
                }
                options.setDraggable(false);
                LatLng location = LatLng.newInstance(facility.getLatitude(), facility.getLongitude());
                Marker marker = new Marker(location, options);
                if (facility.getNumberOfFacilities() > 1) {
                    marker.addMarkerClickHandler(getClusterClickHandler());
                } else {
                    marker.addMarkerClickHandler(getFacilityClickHandler());
                }
                register(marker, facility);
            }
            callback.onRefresh(getMarkers());
        }
    };

    double swLat = bounds.getSouthWest().getLatitude();
    double swLng = bounds.getSouthWest().getLongitude();
    double neLat = bounds.getNorthEast().getLatitude();
    double neLng = bounds.getNorthEast().getLongitude();
    service.get(swLat, swLng, neLat, neLng, serviceCallback);

}

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.oba_application.view.ActiveResultPresenter.java

License:Apache License

public void handleUpdate(StateEvent evevent) {

    State state = evevent.getState();

    if (state instanceof SearchStartedState) {
        reset();//from  w  ww .  j a va 2 s.c om
    } else if (state instanceof SelectedPlaceChangedState) {

        SelectedPlaceChangedState placeChange = (SelectedPlaceChangedState) state;
        reset();

        TimedLocalSearchResult result = placeChange.getSelectedResult();

        if (result != null) {

            LocalSearchResult entry = result.getLocalSearchResult();
            LatLng point = LatLng.newInstance(entry.getLat(), entry.getLon());

            updatWidgetForResult(result);
            openInfoWindowForResult(result);

            Marker m15 = new Marker(point, MarkerOptions.newInstance(getStar15Marker()));
            Marker m20 = new Marker(point, MarkerOptions.newInstance(getStar20Marker()));
            Marker m30 = new Marker(point, MarkerOptions.newInstance(getStar30Marker()));

            _mapOverlayManager.addOverlay(m15, 0, 14);
            _mapOverlayManager.addOverlay(m20, 14, 17);
            _mapOverlayManager.addOverlay(m30, 17, 20);
            _mapOverlayManager.setCenter(point);

            _currentOverlays.add(m15);
            _currentOverlays.add(m20);
            _currentOverlays.add(m30);
        }
    } else if (state instanceof TripPlansState) {
        hideInfoWindow();
        for (Widget widget : _currentDirectionWidgets)
            widget.setVisible(false);
    }
}

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

}