Example usage for com.google.gwt.maps.client.overlays Marker addClickHandler

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

Introduction

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

Prototype

public final HandlerRegistration addClickHandler(final ClickMapHandler handler) 

Source Link

Document

This event is fired when the marker icon was clicked.

Usage

From source file:com.google.gwt.maps.testing.client.maps.InfoWindowMapWidget.java

License:Apache License

private void drawMarker1() {
    LatLng center = LatLng.newInstance(47.8, -121.4);
    MarkerOptions options = MarkerOptions.newInstance();
    options.setPosition(center);//from   w  w w. jav  a  2s  .  c  o  m
    options.setTitle("Hello World");

    final Marker marker = Marker.newInstance(options);
    marker.setMap(mapWidget);

    marker.addClickHandler(new ClickMapHandler() {
        public void onEvent(ClickMapEvent event) {
            drawInfoWindow(marker, event.getMouseEvent());
        }
    });
}

From source file:com.google.gwt.maps.testing.client.maps.StreetViewSideBySideMapWidget.java

License:Apache License

private void processPanoSearch(LatLng latlng, final StreetViewPanoramaData data, StreetViewStatus status) {
    if (status != StreetViewStatus.OK) {
        // TODO error
        return;//from   w  w  w.  j  ava  2s.co m
    }

    if (data == null) {
        // TODO error
        return;
    }

    // setup marker for location clicked
    MarkerOptions options = MarkerOptions.newInstance();
    options.setClickable(true);
    options.setPosition(latlng);
    options.setMap(mapWidget);
    options.setTitle(data.getLocation().getDescription());

    Marker marker = Marker.newInstance(options);

    // move back on click
    marker.addClickHandler(new ClickMapHandler() {
        public void onEvent(ClickMapEvent event) {
            moveStreetView(data);
        }
    });

    // move
    moveStreetView(data);
}

From source file:com.google.sampling.experiential.client.ChartPanel.java

License:Open Source License

private Widget renderEventsOnMap() {
    markers.clear();/*from   w  w w . j  a  v a2 s. c  om*/
    createMap();
    final LatLngBounds bounds = LatLngBounds.newInstance(google, google);
    for (final EventDAO event : data) {
        String latLon = event.getWhatByKey(input.getName());
        if (latLon == null || latLon.length() == 0) {
            continue;
        }
        String[] splits = latLon.split(",");
        if (splits == null || splits.length != 2) {
            continue;
        }
        try {
            double latitude = Double.parseDouble(splits[0]);
            double longitude = Double.parseDouble(splits[1]);

            MarkerOptions markerOptions = MarkerOptions.newInstance();
            markerOptions.setMap(map);
            markerOptions.setTitle(event.getWhatString());
            LatLng newInstance = LatLng.newInstance(latitude, longitude);
            final Marker marker = Marker.newInstance(markerOptions);
            marker.setPosition(newInstance);
            bounds.union(LatLngBounds.newInstance(marker.getPosition(), marker.getPosition()));
            marker.addClickHandler(new ClickMapHandler() {
                @Override
                public void onEvent(ClickMapEvent mapEvent) {
                    openInfoWindowForMarker(event, marker);
                }
            });
            markers.put(event, marker);
        } catch (NumberFormatException nfe) {
        }
    }

    map.fitBounds(bounds);

    final LatLng oldCenter = map.getCenter();
    final int oldZoom = map.getZoom();
    map.addResizeHandler(new ResizeMapHandler() {

        @Override
        public void onEvent(ResizeMapEvent event) {
            map.setCenter(oldCenter);
            map.setZoom(oldZoom);
            map.fitBounds(bounds);
        }
    });
    Window.addResizeHandler(new ResizeHandler() {
        @Override
        public void onResize(ResizeEvent event) {
            MapHandlerRegistration.trigger(map, MapEventType.RESIZE);
            GWT.log("Window has been resized!");
        }
    });
    return map;
}

From source file:com.saveland.ancestry.client.InfoWindowMapWidget.java

License:Apache License

private void addPersonToMap(Person person) {
    final String key = person.key;
    LatLng center = LatLng.newInstance(person.lat, person.lon);
    MarkerOptions options = MarkerOptions.newInstance();
    options.setPosition(center);//from   w  ww .java2s .  com
    options.setTitle(person.getDisplayName());

    final Marker marker = Marker.newInstance(options);
    marker.setMap(mapWidget);

    marker.addClickHandler(new ClickMapHandler() {
        public void onEvent(ClickMapEvent event) {
            drawInfoWindow(key, marker, event.getMouseEvent());
            // fill the form with the person data
            cData.setCurrentPerson(key);
        }
    });
}

From source file:org.rebioma.client.MapView.java

License:Apache License

protected void mapGeocoderResult(JsArray<com.google.gwt.maps.client.services.GeocoderResult> results) {
    String address = geocoder.getAddress();
    StringBuilder sb = new StringBuilder();
    LatLng point = null;/*from w  w  w  . j a  v  a  2s . co m*/
    for (int i = 0; i < results.length(); i++) {
        com.google.gwt.maps.client.services.GeocoderResult geoResult = results.get(i);
        point = geoResult.getGeometry().getLocation();
        MapGeocoderResult result = new MapGeocoderResult(point, address);
        sb.append(result);
        InfoWindowOptions contentOptions = InfoWindowOptions.newInstance();
        contentOptions.setContent(result);
        contentOptions.setPosition(point);
        final InfoWindow content = InfoWindow.newInstance(contentOptions);
        if (geocoderMarkers != null) {
            for (Marker marker : geocoderMarkers) {
                marker.setMap((MapWidget) null);
            }
        }
        Marker geocoderMarker = GeocoderControl.createMarker(point, address);
        geocoderMarker.setMap(map);
        geocoderMarker.addClickHandler(new ClickMapHandler() {
            @Override
            public void onEvent(ClickMapEvent event) {
                closeInfoWindows();
                content.open(map);
                infoWindows.add(content);
            }
        });
        geocoderMarkers.add(geocoderMarker);
    }
    if (results.length() == 1 && point != null) {
        map.setCenter(point);
    }
}

From source file:org.rebioma.client.MapView.java

License:Apache License

private void mapOccurrenceMarkers(List<Occurrence> occurrences) {
    OccurrenceMarkerManager.resetIcons();
    List<Occurrence> unmappableOccs = new ArrayList<Occurrence>();
    for (Occurrence occurrence : occurrences) {
        if (!OccurrenceMarkerManager.isMappable(occurrence)) {
            unmappableOccs.add(occurrence);
            continue;
        }// w ww.  j a  v  a2s.  c  o  m
        final OccurrenceMarkerManager markerManager = OccurrenceMarkerManager.newInstance(occurrence);
        occurrenceMarkers.add(markerManager);
        markerList.addItem(markerManager);
        Marker marker = markerManager.getMarker();
        marker.setMap(map);
        marker.addClickHandler(new ClickMapHandler() {
            @Override
            public void onEvent(ClickMapEvent event) {
                showWindowInfo(markerManager);
            }
        });
    }
    markerList.addUnmappableItems(unmappableOccs);
}

From source file:pl.itrack.client.local.services.maps.AbstractMapService.java

License:Apache License

void addCameraClickHandlers(Integer objectId, Marker marker) {
    marker.addClickHandler(event -> {
        if (!isMarkerLongPressed) {
            final TristarObject cameraDetails = getCameraDetails(objectId);
            showCameraDialog(cameraDetails.getName(), objectId);
        }/*from   w  w  w. j av  a  2s  .c om*/
    });

    marker.addMouseDownHandler(event -> {
        isMarkerLongPressed = false;
        clickedMarkerRelatedObjectId = objectId;
        clickedMarker = marker;
        longPressTimer.schedule(LONG_PRESS_TIME);
    });

    marker.addMouseUpHandler(event -> longPressTimer.cancel());
}

From source file:pl.itrack.client.local.services.maps.TrafficOccurrencesManager.java

License:Apache License

private void addOccurrenceClickHandler(TrafficOccurrenceDto occurrence, Marker marker) {
    marker.addClickHandler(clickEvent -> {
        simpleDialog.show();/*www .j  a  va  2  s .  c o  m*/
        showOccurrenceDetails(Integer.valueOf(occurrence.getId()));
    });
}