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;
}
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()));
}
});
}
}
Aggregations