Added logic to show a testing popup on click on feature
This commit is contained in:
parent
86353ede48
commit
ad701729ee
|
@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType;
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
|
||||||
|
@ -20,6 +21,8 @@ import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.FlexTable;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
|
||||||
import ol.Coordinate;
|
import ol.Coordinate;
|
||||||
|
|
||||||
|
@ -54,7 +57,7 @@ public class LayerManager {
|
||||||
eventBus.addHandler(QueryDataEvent.TYPE, new QueryDataEventHandler() {
|
eventBus.addHandler(QueryDataEvent.TYPE, new QueryDataEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onQueryInteraction(QueryDataEvent queryEvent) {
|
public void onQueryInteraction(final QueryDataEvent queryEvent) {
|
||||||
|
|
||||||
if(queryEvent.getGeoQuery()!=null) {
|
if(queryEvent.getGeoQuery()!=null) {
|
||||||
GeoQuery selectDataInfo = queryEvent.getGeoQuery();
|
GeoQuery selectDataInfo = queryEvent.getGeoQuery();
|
||||||
|
@ -106,6 +109,33 @@ public class LayerManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<GeoNaDataObject> result) {
|
public void onSuccess(List<GeoNaDataObject> result) {
|
||||||
|
|
||||||
|
if(result==null || result.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
GWT.log("Data result: "+result);
|
||||||
|
|
||||||
|
FlexTable flex = new FlexTable();
|
||||||
|
flex.setCellPadding(1);
|
||||||
|
flex.setCellSpacing(1);
|
||||||
|
flex.getElement().addClassName("popup-table");
|
||||||
|
for (GeoNaDataObject geoNaDataObject : result) {
|
||||||
|
Map<String, List<String>> entries = geoNaDataObject.getDataEntryFields();
|
||||||
|
|
||||||
|
for (String key : entries.keySet()) {
|
||||||
|
if(key.equalsIgnoreCase("nome")) {
|
||||||
|
flex.setHTML(0, 0, new HTML(entries.get(key).get(0)).toString());
|
||||||
|
}
|
||||||
|
else if(key.equalsIgnoreCase("descrizione")) {
|
||||||
|
flex.setText(1, 0, entries.get(key).get(0));
|
||||||
|
}else if(key.equalsIgnoreCase("date_scavo")) {
|
||||||
|
flex.setHTML(2, 0, new HTML("<code>"+entries.get(key).get(0)).toString()+"</code>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break; //Only the first one
|
||||||
|
}
|
||||||
|
|
||||||
|
olMap.showPopup(flex.toString(), queryEvent.getoLCoordinate());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,8 +171,6 @@ public class OpenLayerOSM {
|
||||||
eventBus.fireEvent(new QueryDataEvent(select,coordinate));
|
eventBus.fireEvent(new QueryDataEvent(select,coordinate));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -65,10 +65,11 @@ public class FeatureParser {
|
||||||
GeoNaDataObject gdo = new GeoNaDataObject();
|
GeoNaDataObject gdo = new GeoNaDataObject();
|
||||||
gdo.setLayerItem(layerItem);
|
gdo.setLayerItem(layerItem);
|
||||||
for (FeatureRow featureRow : rows) {
|
for (FeatureRow featureRow : rows) {
|
||||||
|
gdo.setDataEntryFields(featureRow.getMapProperties());
|
||||||
}
|
}
|
||||||
|
listGeonaDO.add(gdo);
|
||||||
}
|
}
|
||||||
return null;
|
return listGeonaDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,14 +118,22 @@ public class FeatureParser {
|
||||||
return listFeaturesRow;
|
return listFeaturesRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject crs = json.getJSONObject("crs");
|
String featureCRSName = "";
|
||||||
JSONObject crsProp = crs.getJSONObject("properties");
|
try {
|
||||||
|
JSONObject crs = json.getJSONObject("crs");
|
||||||
|
JSONObject crsProp = crs.getJSONObject("properties");
|
||||||
|
featureCRSName = crsProp.getString("name");
|
||||||
|
LOG.info("Crs name found: "+featureCRSName);
|
||||||
|
}catch (Exception e) {
|
||||||
|
LOG.warn("Unable to read the field 'crs'");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
LOG.info("Features are: "+features.length());
|
LOG.info("Features are: "+features.length());
|
||||||
|
|
||||||
for (int i=0; i<features.length(); i++) {
|
for (int i=0; i<features.length(); i++) {
|
||||||
final FeatureRow row = new FeatureRow();
|
final FeatureRow row = new FeatureRow();
|
||||||
|
row.setCrsName(featureCRSName);
|
||||||
JSONObject theFeature = ((JSONObject)features.get(i));
|
JSONObject theFeature = ((JSONObject)features.get(i));
|
||||||
LOG.debug("Building at index: "+i);
|
LOG.debug("Building at index: "+i);
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
width: 0;
|
width: 0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ol-popup:after {
|
.ol-popup:after {
|
||||||
|
@ -63,3 +64,7 @@
|
||||||
.ol-popup-closer:after {
|
.ol-popup-closer:after {
|
||||||
content: "✖";
|
content: "✖";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.popup-table div:first-child {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
Loading…
Reference in New Issue