Mercurial > hg > STI-GWT
changeset 75:d69066d16e45 trimmed_data
load overlays from data-file
author | Sebastian Kruse <skruse@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 15 Jan 2013 16:32:25 +0100 |
parents | caca95f925cc |
children | 731a2f32978c |
files | src/econnect/wp3_3/client/widgets/map/Map.java src/econnect/wp3_3/client/widgets/map/StiMap.java war/overlaysources.json war/scripts/sti/STICore.js war/scripts/sti/STIMap.js |
diffstat | 5 files changed, 43 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/econnect/wp3_3/client/widgets/map/Map.java Mon Jan 14 14:37:26 2013 +0100 +++ b/src/econnect/wp3_3/client/widgets/map/Map.java Tue Jan 15 16:32:25 2013 +0100 @@ -147,17 +147,17 @@ 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() { + + for( int i=0; i<this.jsMap.getOverlayCount(); i++ ){ + final int index = i; + overlayMenu.addItem(this.jsMap.getOverlayName(index), new Command() { public void execute() { - jsMap.setOverlay(0); + jsMap.setOverlay(index); RootPanel.get().remove(overlayMenu); overlay.setUrl(constants.addImage()); } }); - //} + } overlayMenu.addStyleName("zHigh"); overlay.setTitle(textConstants.overlayLayers());
--- a/src/econnect/wp3_3/client/widgets/map/StiMap.java Mon Jan 14 14:37:26 2013 +0100 +++ b/src/econnect/wp3_3/client/widgets/map/StiMap.java Tue Jan 15 16:32:25 2013 +0100 @@ -65,6 +65,24 @@ }-*/; /** + * Getter for number of overlays + * + * @return the number of overlays + */ + public final native int getOverlayCount() /*-{ + return this.core.overlays.length; + }-*/; + + /** + * Getter for the name of a specific base layer + * + * @return the name of a specific base layer + */ + public final native String getOverlayName( int index ) /*-{ + return this.core.overlays[index].label; + }-*/; + + /** * Setter for the top base layer * * @param index the index of the base layer to set
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/war/overlaysources.json Tue Jan 15 16:32:25 2013 +0100 @@ -0,0 +1,7 @@ +[ + { + "label": "Limes", + "url": "/data/overlay/limes.kml" + }, + +] \ No newline at end of file
--- a/war/scripts/sti/STICore.js Mon Jan 14 14:37:26 2013 +0100 +++ b/war/scripts/sti/STICore.js Tue Jan 15 16:32:25 2013 +0100 @@ -223,6 +223,14 @@ catch(e){ } + this.overlays = []; + try { + var jsonString = this.getFileString("overlaysources.json"); + this.overlays = eval('(' + jsonString + ')'); + } + catch(e){ + } + this.lockScreenContainer = document.createElement("div"); this.lockScreenContainer.setAttribute('class','lockScreenContainer'); document.getElementById("mainContainer").appendChild(this.lockScreenContainer);
--- a/war/scripts/sti/STIMap.js Mon Jan 14 14:37:26 2013 +0100 +++ b/war/scripts/sti/STIMap.js Tue Jan 15 16:32:25 2013 +0100 @@ -1377,22 +1377,20 @@ } else { - var limesLayer = new OpenLayers.Layer.Vector("KML", { + var newLayer = new OpenLayers.Layer.Vector("KML", { projection: this.openlayersMap.displayProjection, strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ - url: "data/overlay/limes.kml", + url: this.core.overlays[index].url, format: new OpenLayers.Format.KML({ extractStyles: true, extractAttributes: true }) }) }); - this.openlayersMap.addLayer(limesLayer); + this.openlayersMap.addLayer(newLayer); - this.overlayLayers[index] = limesLayer; - - //limesLayer.setVisibility(true); + this.overlayLayers[index] = newLayer; } },