Search in sources :

Example 1 with CircleMarkerOptions

use of org.peimari.gleaflet.client.CircleMarkerOptions in project v-leaflet by mstahv.

the class LeafletCircleMarkerConnector method createOptions.

@Override
protected CircleMarkerOptions createOptions() {
    CircleMarkerOptions o = super.createOptions();
    LeafletCircleState s = getState();
    if (s.radius != null) {
        o.setRadius(s.radius);
    }
    return o;
}
Also used : LeafletCircleState(org.vaadin.addon.leaflet.shared.LeafletCircleState) CircleMarkerOptions(org.peimari.gleaflet.client.CircleMarkerOptions)

Example 2 with CircleMarkerOptions

use of org.peimari.gleaflet.client.CircleMarkerOptions in project v-leaflet by mstahv.

the class LeafletCircleMarkerConnector method update.

@Override
protected void update() {
    if (marker != null) {
        removeLayerFromParent();
        marker.removeClickListener();
        marker.removeMouseOverListener();
        marker.removeMouseOutListener();
        marker.removeContextMenuListener();
    }
    LatLng latlng = LatLng.create(getState().point.getLat(), getState().point.getLon());
    CircleMarkerOptions options = createOptions();
    marker = CircleMarker.create(latlng, options);
    final double radius = getState().radius;
    // TODO workaround to Leaflet bug, report
    marker.setRadius(radius);
    addToParent(marker);
    marker.addClickListener(new ClickListener() {

        @Override
        public void onClick(MouseEvent event) {
            rpc.onClick(U.toPoint(event.getLatLng()), MouseEventDetailsBuilder.buildMouseEventDetails(event.getNativeEvent(), getLeafletMapConnector().getWidget().getElement()));
        }
    });
    if (hasEventListener(EventId.MOUSEOVER)) {
        /*
			 * Add listener lazily to avoid extra event if layer is modified in
			 * server side listener. This can be removed if "clear and rebuild"
			 * style component updates are changed into something more
			 * intelligent at some point.
             */
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                marker.addMouseOverListener(new MouseOverListener() {

                    @Override
                    public void onMouseOver(MouseEvent event) {
                        mouseOverRpc.onMouseOver(U.toPoint(event.getLatLng()));
                    }
                });
            }
        });
    }
    if (hasEventListener(EventId.MOUSEOUT)) {
        marker.addMouseOutListener(new MouseOutListener() {

            @Override
            public void onMouseOut(MouseEvent event) {
                mouseOutRpc.onMouseOut(U.toPoint(event.getLatLng()));
            }
        });
    }
    if (hasEventListener(EventId.CONTEXTMENU)) {
        marker.addContextMenuListener(new ContextMenuListener() {

            @Override
            public void onContextMenu(MouseEvent event) {
                contextMenuRpc.onContextMenu(U.toPoint(event.getLatLng()), MouseEventDetailsBuilder.buildMouseEventDetails(event.getNativeEvent(), getLeafletMapConnector().getWidget().getElement()));
            }
        });
    }
}
Also used : MouseOutListener(org.peimari.gleaflet.client.MouseOutListener) MouseEvent(org.peimari.gleaflet.client.MouseEvent) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) MouseOverListener(org.peimari.gleaflet.client.MouseOverListener) CircleMarkerOptions(org.peimari.gleaflet.client.CircleMarkerOptions) ContextMenuListener(org.peimari.gleaflet.client.ContextMenuListener) LatLng(org.peimari.gleaflet.client.LatLng) ClickListener(org.peimari.gleaflet.client.ClickListener)

Aggregations

CircleMarkerOptions (org.peimari.gleaflet.client.CircleMarkerOptions)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 ClickListener (org.peimari.gleaflet.client.ClickListener)1 ContextMenuListener (org.peimari.gleaflet.client.ContextMenuListener)1 LatLng (org.peimari.gleaflet.client.LatLng)1 MouseEvent (org.peimari.gleaflet.client.MouseEvent)1 MouseOutListener (org.peimari.gleaflet.client.MouseOutListener)1 MouseOverListener (org.peimari.gleaflet.client.MouseOverListener)1 LeafletCircleState (org.vaadin.addon.leaflet.shared.LeafletCircleState)1