use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.
the class AreaPolygon method onClick$btnClear.
public void onClick$btnClear(Event event) {
MapComposer mc = getMapComposer();
if (layerName != null && mc.getMapLayer(layerName) != null) {
mc.removeLayer(layerName);
}
String script = mc.getOpenLayersJavascript().addPolygonDrawingTool();
mc.getOpenLayersJavascript().execute(mc.getOpenLayersJavascript().getIFrameReferences() + script);
displayGeom.setValue("");
btnNext.setDisabled(true);
btnClear.setDisabled(true);
invalidWKT.setValue("");
}
use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.
the class AreaPolygon method onSelectionGeom.
/**
* @param event
*/
public void onSelectionGeom(Event event) {
String selectionGeom = (String) event.getData();
try {
String wkt = "";
if (selectionGeom.contains(StringConstants.NAN_NAN)) {
displayGeom.setValue("");
} else {
wkt = selectionGeom;
displayGeom.setValue(wkt);
}
//get the current MapComposer instance
MapComposer mc = getMapComposer();
//add feature to the map as a new layer
if (wkt.length() > 0) {
layerName = (mc.getMapLayer(txtLayerName.getValue()) == null) ? txtLayerName.getValue() : mc.getNextAreaLayerName(txtLayerName.getValue());
MapLayer mapLayer = mc.addWKTLayer(wkt, layerName, txtLayerName.getValue());
mapLayer.getMapLayerMetadata().setMoreInfo(LayersUtil.getMetadataForWKT(CommonData.lang("metadata_polygon"), wkt));
if (!validWKT(wkt)) {
btnNext.setDisabled(true);
btnClear.setDisabled(false);
} else {
btnClear.setDisabled(false);
btnNext.setDisabled(false);
}
}
} catch (Exception e) {
LOGGER.error("error mapping user polygon", e);
btnNext.setDisabled(true);
btnClear.setDisabled(false);
}
}
use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.
the class AreaRadiusManual method createCircle.
public void createCircle() {
String wkt = Util.createCircleJs(dLongitude.getValue(), dLatitude.getValue(), dRadius.getValue() * 1000.0);
if (!StringConstants.NONE.equalsIgnoreCase(wkt)) {
try {
MapComposer mc = getMapComposer();
layerName = (mc.getMapLayer(txtLayerName.getValue()) == null) ? txtLayerName.getValue() : mc.getNextAreaLayerName(txtLayerName.getValue());
MapLayer mapLayer = mc.addWKTLayer(wkt, layerName, txtLayerName.getValue());
mapLayer.getMapLayerMetadata().setMoreInfo(LayersUtil.getMetadata(dRadius.getText() + "km radius around longitude " + dLongitude.getText() + ", latitude " + dLatitude.getText()));
displayGeom.setText(wkt);
} catch (Exception e) {
LOGGER.error("Error adding WKT layer", e);
}
}
}
use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.
the class VisibilityToggleEventListener method onEvent.
@Override
public void onEvent(Event event) throws Exception {
LOGGER.debug("VisibilityToggleEventListener.onEvent() fired ");
Checkbox checkbox = (Checkbox) event.getTarget();
try {
MapComposer mapComposer = (MapComposer) event.getPage().getFellow(StringConstants.MAPPORTALPAGE);
if (mapComposer.safeToPerformMapAction()) {
Listitem listitem = (Listitem) checkbox.getParent().getParent();
MapLayer layer = listitem.getValue();
boolean checked = checkbox.isChecked();
/* checkbox state will be saved automatically in MapLayer instances
* with calls to activate/remove in OpenLayersJavascript
*/
if (checked) {
PortalSession portalSession = (PortalSession) Executions.getCurrent().getDesktop().getSession().getAttribute(StringConstants.PORTAL_SESSION);
openLayersJavascript.execute(openLayersJavascript.getIFrameReferences() + openLayersJavascript.activateMapLayer(layer, false, true) + openLayersJavascript.updateMapLayerIndexes(portalSession.getActiveLayers()));
checkbox.setTooltiptext("Hide");
mapComposer.refreshContextualMenu();
} else {
openLayersJavascript.removeMapLayerNow(layer);
checkbox.setTooltiptext("Show");
mapComposer.refreshContextualMenu();
}
} else {
/* there was a problem performing the action - 'undo'
* the user's click on the checkbox
*/
checkbox.setChecked(!checkbox.isChecked());
}
} catch (Exception e) {
//toogle won't work if page not completely loaded.
}
}
use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.
the class ActiveLayersRemoveEventListener method onEvent.
@Override
public void onEvent(Event event) throws Exception {
MapComposer mapComposer = getMapComposer(event);
if (mapComposer != null && mapComposer.safeToPerformMapAction()) {
// get reference to the label/image the user clicked on
Component target = event.getTarget();
Listitem listItem = (Listitem) target.getParent().getParent();
MapLayer activeLayer = listItem.getValue();
if (activeLayer != null) {
mapComposer.deactiveLayer(activeLayer, true, false);
}
} else {
LOGGER.debug("MapController reports unsafe to perform action");
}
}
Aggregations