Example usage for com.google.gwt.maps.client.overlays.overlayhandlers OverlayViewOnAddHandler OverlayViewOnAddHandler

List of usage examples for com.google.gwt.maps.client.overlays.overlayhandlers OverlayViewOnAddHandler OverlayViewOnAddHandler

Introduction

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

Prototype

OverlayViewOnAddHandler

Source Link

Usage

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

License:Apache License

private void drawOverlay_Generic_OverlayView() {
    OverlayViewOnDrawHandler onDrawHandler = new OverlayViewOnDrawHandler() {
        @Override// w w w .  ja  v a 2s.  co  m
        public void onDraw(OverlayViewMethods methods) {
            MapCanvasProjection projection = methods.getProjection();
            LatLng sw = LatLng.newInstance(40.710216, -74.213393);
            Point p = projection.fromLatLngToDivPixel(sw);
            htmlOverlayMessage.getElement().getStyle().setPosition(Position.ABSOLUTE);
            htmlOverlayMessage.getElement().getStyle().setLeft(p.getX(), Unit.PX);
            htmlOverlayMessage.getElement().getStyle().setTop(p.getY(), Unit.PX);

            String message = "OverlayView draw() called... the projection world width is "
                    + projection.getWorldWidth();
            htmlOverlayMessage.clear();
            htmlOverlayMessage.add(new HTML(message));
            System.out.println(message);
        }
    };

    OverlayViewOnAddHandler onAddHandler = new OverlayViewOnAddHandler() {
        @Override
        public void onAdd(OverlayViewMethods methods) {
            MapCanvasProjection projection = methods.getProjection();
            String message = "OverlayView add() called... the projection world width is "
                    + projection.getWorldWidth();
            System.out.println(message);

            methods.getPanes().getFloatPane().appendChild(htmlOverlayMessage.getElement());
        }
    };

    OverlayViewOnRemoveHandler onRemoveHandler = new OverlayViewOnRemoveHandler() {
        @Override
        public void onRemove(OverlayViewMethods methods) {
            String message = "OverlayView remove() called...";
            System.out.println(message);

            // remove existing nodes
            htmlOverlayMessage.getElement().removeFromParent();
        }
    };

    customOverlayView = OverlayView.newInstance(mapWidget, onDrawHandler, onAddHandler, onRemoveHandler);
}