Skip to content

Commit

Permalink
Fixed bug when no additional map layers defined
Browse files Browse the repository at this point in the history
  • Loading branch information
guygriffiths committed Feb 6, 2018
1 parent 3149ebe commit ee26b48
Showing 1 changed file with 32 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1327,36 +1327,39 @@ public void onLayerChanged(MapLayerChangedEvent eventObject) {
/*
* Now add any additional user-defined layers
*/
for (FixedLayerDetails layer : additionalLayers) {
try {
wmsOptions = new WMSOptions();
wmsOptions.setProjection(layer.projection);
wmsOptions.setWrapDateLine(true);
wmsOptions.setTransitionEffect(TransitionEffect.MAP_RESIZE);
wmsOptions.setIsBaseLayer(layer.isBaseLayer);
if (layer.projection.equalsIgnoreCase("EPSG:3857")
|| layer.projection.equalsIgnoreCase("EPSG:900913")) {
wmsOptions.setMaxExtent(webMercExtent);
wmsOptions.setMaxResolution(webMercMaxResolution);
}
wmsParams = new WMSParams();
wmsParams.setLayers(layer.layerNames);
wmsParams.setFormat(layer.imageFormat);
wmsParams.setTransparent(true);
wmsParams.setParameter("version", layer.version);
WMS userLayer = new WMS(layer.title, layer.wmsUrl, wmsParams, wmsOptions);
overLayers.put(userLayer.getId(), layer);
userLayer.setIsVisible(false);
map.addLayer(userLayer);
if (!layer.isBaseLayer && layer.isOn) {
userLayer.setIsVisible(true);
} else {
}
if (layer.isBaseLayer && layer.isOn) {
map.setBaseLayer(userLayer);
if (additionalLayers != null) {
for (FixedLayerDetails layer : additionalLayers) {
try {
wmsOptions = new WMSOptions();
wmsOptions.setProjection(layer.projection);
wmsOptions.setWrapDateLine(true);
wmsOptions.setTransitionEffect(TransitionEffect.MAP_RESIZE);
wmsOptions.setIsBaseLayer(layer.isBaseLayer);
if (layer.projection.equalsIgnoreCase("EPSG:3857")
|| layer.projection.equalsIgnoreCase("EPSG:900913")) {
wmsOptions.setMaxExtent(webMercExtent);
wmsOptions.setMaxResolution(webMercMaxResolution);
}
wmsParams = new WMSParams();
wmsParams.setLayers(layer.layerNames);
wmsParams.setFormat(layer.imageFormat);
wmsParams.setTransparent(true);
wmsParams.setParameter("version", layer.version);
WMS userLayer = new WMS(layer.title, layer.wmsUrl, wmsParams, wmsOptions);
overLayers.put(userLayer.getId(), layer);
userLayer.setIsVisible(false);
map.addLayer(userLayer);
if (!layer.isBaseLayer && layer.isOn) {
userLayer.setIsVisible(true);
} else {
}
if (layer.isBaseLayer && layer.isOn) {
map.setBaseLayer(userLayer);
}
} catch (Exception e) {
GWT.log("Problem adding custom map layer. Ignoring this layer: " + layer.title,
e);
}
} catch (Exception e) {
GWT.log("Problem adding custom map layer. Ignoring this layer: " + layer.title, e);
}
}
}
Expand Down

0 comments on commit ee26b48

Please sign in to comment.