|
|
|
@ -24,6 +24,7 @@ import com.google.gwt.uibinder.client.UiBinder;
|
|
|
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
|
|
|
import com.google.gwt.user.client.Random;
|
|
|
|
|
import com.google.gwt.user.client.ui.Composite;
|
|
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
|
|
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
|
|
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
|
|
|
import com.google.gwt.user.client.ui.RadioButton;
|
|
|
|
@ -58,7 +59,7 @@ public class MapView extends Composite {
|
|
|
|
|
HTMLPanel panelBaseLayers;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
HTMLPanel theMap;
|
|
|
|
|
HTMLPanel theMapPanel;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
DropdownButton linkMap;
|
|
|
|
@ -67,6 +68,8 @@ public class MapView extends Composite {
|
|
|
|
|
HorizontalPanel coordinatePanel;
|
|
|
|
|
|
|
|
|
|
private LightOpenLayerMap lightOLSM;
|
|
|
|
|
|
|
|
|
|
private HTML attributionDiv = null;
|
|
|
|
|
|
|
|
|
|
private String theMapId = null;
|
|
|
|
|
|
|
|
|
@ -79,9 +82,9 @@ public class MapView extends Composite {
|
|
|
|
|
public MapView(Coordinate centerTo, int zoom, String internalMapWidth, String internalMapHeight) {
|
|
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
|
|
|
theMapId = "map" + Random.nextInt();
|
|
|
|
|
theMap.getElement().setId(theMapId);
|
|
|
|
|
theMap.setWidth(internalMapWidth);
|
|
|
|
|
theMap.setHeight(internalMapHeight);
|
|
|
|
|
theMapPanel.getElement().setId(theMapId);
|
|
|
|
|
theMapPanel.setWidth(internalMapWidth);
|
|
|
|
|
theMapPanel.setHeight(internalMapHeight);
|
|
|
|
|
|
|
|
|
|
linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
|
|
|
|
|
|
|
|
|
@ -101,7 +104,7 @@ public class MapView extends Composite {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setBaseLayers() {
|
|
|
|
|
protected void setBaseLayers() {
|
|
|
|
|
List<BaseMapLayer> listBaseLayers = GeoportalDataViewer.getListBaseMapLayers();
|
|
|
|
|
|
|
|
|
|
if(listBaseLayers==null)
|
|
|
|
@ -117,15 +120,15 @@ public class MapView extends Composite {
|
|
|
|
|
radio.setText(baseMapLayer.getName());
|
|
|
|
|
if(i==0) {
|
|
|
|
|
radio.setValue(true, false);
|
|
|
|
|
setMapAttribution(baseMapLayer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
radio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onValueChange(ValueChangeEvent<Boolean> event) {
|
|
|
|
|
//applicationBus.fireEvent(new ChangeMapLayerEvent(baseMapLayer));
|
|
|
|
|
lightOLSM.changeBaseMap(baseMapLayer);
|
|
|
|
|
|
|
|
|
|
setMapAttribution(baseMapLayer);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -137,6 +140,22 @@ public class MapView extends Composite {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setMapAttribution(BaseMapLayer baseMapLayer) {
|
|
|
|
|
|
|
|
|
|
if(attributionDiv!=null)
|
|
|
|
|
theMapPanel.remove(attributionDiv);
|
|
|
|
|
|
|
|
|
|
String attributionHTML = "<div class='map-internal-credits'><div class='map-internal-credits-container'>"
|
|
|
|
|
+ baseMapLayer.getAttribution() + "</div></div>";
|
|
|
|
|
attributionDiv = new HTML();
|
|
|
|
|
|
|
|
|
|
// THE OSM Contributors are automatically added by gwt-ol, others ones not.
|
|
|
|
|
if (!baseMapLayer.getType().equals(BaseMapLayer.OL_BASE_MAP.OSM)) {
|
|
|
|
|
attributionDiv.setHTML(attributionHTML);
|
|
|
|
|
theMapPanel.add(attributionDiv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setMapSize() {
|
|
|
|
@ -144,8 +163,8 @@ public class MapView extends Composite {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void execute() {
|
|
|
|
|
int width = theMap.getParent().getOffsetWidth();
|
|
|
|
|
int height = theMap.getParent().getOffsetHeight();
|
|
|
|
|
int width = theMapPanel.getParent().getOffsetWidth();
|
|
|
|
|
int height = theMapPanel.getParent().getOffsetHeight();
|
|
|
|
|
if (width == 0)
|
|
|
|
|
width = 300;
|
|
|
|
|
|
|
|
|
@ -153,7 +172,7 @@ public class MapView extends Composite {
|
|
|
|
|
height = 300;
|
|
|
|
|
|
|
|
|
|
GWT.log("Internal Map w: " + width + ", h: " + height);
|
|
|
|
|
theMap.setSize(width + "px", height + "px");
|
|
|
|
|
theMapPanel.setSize(width + "px", height + "px");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|