Mercurial > hg > STI-GWT
changeset 61:eac73bf1ce6e CellTable
add overlay functionality (beta)
author | Sebastian Kruse <skruse@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 14 Dec 2012 16:33:36 +0100 |
parents | 6f2d2b6f969a |
children | 6d8f3ff53429 |
files | src/econnect/wp3_3/client/core/StiConstants.java src/econnect/wp3_3/client/widgets/map/Map.java src/econnect/wp3_3/client/widgets/map/StiMap.java war/scripts/sti/STIMap.js |
diffstat | 4 files changed, 82 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/econnect/wp3_3/client/core/StiConstants.java Fri Dec 14 16:32:55 2012 +0100 +++ b/src/econnect/wp3_3/client/core/StiConstants.java Fri Dec 14 16:33:36 2012 +0100 @@ -67,6 +67,9 @@ @DefaultStringValue("Choose from different map types") String mapLayers(); + @DefaultStringValue("Choose from different overlay types") + String overlayLayers(); + @DefaultStringValue("Animation Control for a selected time range") String animation0();
--- a/src/econnect/wp3_3/client/widgets/map/Map.java Fri Dec 14 16:32:55 2012 +0100 +++ b/src/econnect/wp3_3/client/widgets/map/Map.java Fri Dec 14 16:33:36 2012 +0100 @@ -140,14 +140,49 @@ maps.setUrl(constants.mapsImage()); } } - }); - - final Grid controlGrid = new Grid(5,1); + }); + + //TODO: add correct (better) image + final Image overlay = new Image(constants.addImage()); + final MenuBar overlayMenu = new MenuBar(true); + + overlayMenu.setAnimationEnabled(true); + //TODO: add overlays from data + //for( int i=0; i<this.jsMap.getMapCount(); i++ ){ + // final int index = i; + overlayMenu.addItem("Limes", new Command() { + public void execute() { + jsMap.setOverlay(0); + RootPanel.get().remove(overlayMenu); + overlay.setUrl(constants.addImage()); + } + }); + //} + overlayMenu.addStyleName("zHigh"); + + overlay.setTitle(textConstants.overlayLayers()); + overlay.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent event) { + if( !RootPanel.get().remove(overlay) ){ + //TODO: set correct (better) image + overlay.setUrl(constants.addClickImage()); + int left = overlay.getParent().getAbsoluteLeft() + overlay.getParent().getOffsetWidth() + 3; + int top = overlay.getAbsoluteTop(); + RootPanel.get().add(overlayMenu, left, top); + } + else { + overlay.setUrl(constants.addImage()); + } + } + }); + + final Grid controlGrid = new Grid(6,1); controlGrid.setWidget(1, 0, maps); controlGrid.setWidget(2, 0, this.navigate.getButton()); controlGrid.setWidget(3, 0, drilldown); // controlGrid.setWidget(4, 0, add.getButton()); - controlGrid.setWidget(4, 0, connections); + controlGrid.setWidget(4, 0, overlay); + controlGrid.setWidget(5, 0, connections); final int levels = this.jsMap.getNumZoomLevels(); DivElement zoomDiv = Document.get().createDivElement();
--- a/src/econnect/wp3_3/client/widgets/map/StiMap.java Fri Dec 14 16:32:55 2012 +0100 +++ b/src/econnect/wp3_3/client/widgets/map/StiMap.java Fri Dec 14 16:33:36 2012 +0100 @@ -65,6 +65,15 @@ }-*/; /** + * Setter for the top base layer + * + * @param index the index of the base layer to set + */ + public final native void setOverlay( int index ) /*-{ + this.setOverlay(index); + }-*/; + + /** * Getter for the number of zoom levels; depends on the number of zoomlevels which is coded in the js source * * @return the number of zoom levels
--- a/war/scripts/sti/STIMap.js Fri Dec 14 16:32:55 2012 +0100 +++ b/war/scripts/sti/STIMap.js Fri Dec 14 16:33:36 2012 +0100 @@ -14,6 +14,7 @@ this.container = container; this.openlayersMap; this.baseLayers; + this.overlayLayers; this.objectLayer; this.drilldownLayer; this.connectionLayer; @@ -53,6 +54,8 @@ * it includes setting up all layers of the map and defines all map specific interaction possibilities */ initialize: function(){ + + this.overlayLayers = new Array(); //OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url="; var map = this; @@ -578,7 +581,6 @@ if( this.core.props.historicMaps ){ this.setCanvas(); } - }, /** @@ -1365,6 +1367,34 @@ this.openlayersMap.zoomTo(Math.floor(this.openlayersMap.getZoom()+0.05)); this.openlayersMap.setBaseLayer(this.baseLayers[index]); }, + + setOverlay: function(index){ + + if (this.overlayLayers[index] instanceof OpenLayers.Layer.Vector) { + + this.openlayersMap.removeLayer(this.overlayLayers[index]); + this.overlayLayers[index] = null; + + } else { + + var limesLayer = new OpenLayers.Layer.Vector("KML", { + projection: this.openlayersMap.displayProjection, + strategies: [new OpenLayers.Strategy.Fixed()], + protocol: new OpenLayers.Protocol.HTTP({ + url: "data/overlay/limes.kml", + format: new OpenLayers.Format.KML({ + extractStyles: true, + extractAttributes: true + }) + }) + }); + this.openlayersMap.addLayer(limesLayer); + + this.overlayLayers[index] = limesLayer; + + //limesLayer.setVisibility(true); + } + }, configure: function(zoom,cLon,cLat,mapId){ this.openlayersMap.zoomTo(zoom);