Skip to content

Commit

Permalink
Version 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
cmndrbensisko committed Feb 9, 2015
1 parent f3cb587 commit 2542496
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ LocalLayerWidget 1.4

The LocalLayer Widget for ArcGIS Web AppBuilder is intended to allow the direct addition of ArcGIS for Server Mapservices to an ArcGIS Web AppBuilder application, without needing to wrap the desired services in an ArcGIS Online/Portal Web Map. The Legend, LayerList, and AttributeTable widgets should continue to work with your local layers.

:bulb: In addition to the setup steps below, Rebecca Strauch generously provides and updates a living document of Tips and Tricks for implementing and using this widget. Please find it on her GeoNet blog located [here](https://geonet.esri.com/blogs/myAlaskaGIS/2015/02/04/tips-for-using-the-custom-locallayer-widget-with-wab-dev-edition).

###Setting up the Widget

Please note that this is not an in-panel widget. To add it to your ArcGIS Web AppBuilder, add the widget to your \client\stemapp\widgets directory, and add a reference to the widget in the standard default2Dapp configuration located at \client\builder\predefined-apps\default2DApp\config.json, under the widgetOnScreen section.
Expand Down Expand Up @@ -61,3 +63,17 @@ Example:
```
1. open the client\stemapp\themes\TabTheme\layouts\default\config.json in a text editor and add the code block above. This will take care of adding the Local Layer widget to default

:bulb: If you would like labels to display on your Feature Services by default, make sure to add "showLabels":true under the mapOptions setting of your config.json file located under \client\stemapp\ (or at the root of your current app), in addition to checking the "Show Labels?" checkbox under the Feature Layer Settings Menu. Please note that there is currently an ESRI API bug preventing complex labelling expressions from being displayed on Feature Layers, such as expressions containing the CONCAT operator, and hopefully this will be addressed by esri in future releases.

```
Example:
"map": {
...
"mapOptions": {
"showLabels":true,
"extent": {
...
}
}
}
```
26 changes: 23 additions & 3 deletions Widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ define([
'esri/urlUtils',
'dojo/_base/array',
'dojo/_base/query',
"dojo/_base/connect",
'esri/layers/ArcGISDynamicMapServiceLayer',
'esri/layers/ArcGISTiledMapServiceLayer',
'esri/layers/FeatureLayer',
Expand All @@ -26,6 +27,7 @@ define([
urlUtils,
array,
query,
connect,
ArcGISDynamicMapServiceLayer,
ArcGISTiledMapServiceLayer,
FeatureLayer,
Expand All @@ -42,8 +44,13 @@ define([

onClose: function(){
if (query('.jimu-popup.widget-setting-popup', window.parent.document).length === 0){
var changedData = {itemId:this._originalWebMap};
MapManager.getInstance(ConfigManager.getConfig(),this._originalWebMap).onAppConfigChanged(ConfigManager.getConfig(),'mapChange', changedData);
var _currentExtent = dojo.clone(this.map.extent);
var _changedData = {itemId:this._originalWebMap};
var _newBasemap = connect.subscribe("mapChanged", function(_map){
_newBasemap.remove();
_map.setExtent(_currentExtent)
})
MapManager.getInstance().onAppConfigChanged(ConfigManager.getConfig(),'mapChange', _changedData);
}
},

Expand Down Expand Up @@ -121,8 +128,18 @@ define([
lLayer.on('load',function(evt){
var removeLayers = [];
array.forEach(evt.layer.visibleLayers,function(layer){
if (evt.layer.layerInfos[layer].parentLayerId>-1){
//remove any grouplayers
if (evt.layer.layerInfos[layer].subLayerIds){
removeLayers.push(layer);
}else{
var isParentInvisible = false;
var _layerCheck = dojo.clone(layer)
while (evt.layer.layerInfos[_layerCheck].parentLayerId > -1){
if (evt.layer.visibleLayers.indexOf(evt.layer.layerInfos[_layerCheck].parentLayerId) == -1){
removeLayers.push(layer);
}
_layerCheck = dojo.clone(evt.layer.layerInfos[_layerCheck].parentLayerId)
}
}
});
array.forEach(removeLayers,function(layerId){
Expand Down Expand Up @@ -152,6 +169,9 @@ define([
if(layer.hasOwnProperty('autorefresh')){
lOptions.refreshInterval = layer.autorefresh;
}
if(layer.hasOwnProperty('showLabels')){
lOptions.showLabels = true;
}
lLayer = new FeatureLayer(layer.url, lOptions);
this._viewerMap.addLayer(lLayer);
}else if(layer.type.toUpperCase() === 'TILED'){
Expand Down
21 changes: 21 additions & 0 deletions setting/FeatureLayerEdit.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,27 @@
</table>
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%;" cellspacing="0">
<tr>
<td style="width:50%;">
<table style="width:100%;" cellspacing="0">
<tbody>
<tr>
<td style="width:220px;text-align:left;">
<span>${nls.showLabels}</span>
</td>
<td style="width:auto;">
<div data-dojo-type="jimu/dijit/CheckBox" data-dojo-attach-point="showLabelsCbx" />
</td>
</tr>
</tbody>
</table>
</td>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<table style="width:100%;" cellspacing="0">
Expand Down
6 changes: 6 additions & 0 deletions setting/FeatureLayerEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ define(
if(config.hasOwnProperty('autorefresh')){
this.autoRefresh.set('value', config.autorefresh);
}
if(config.showLabels === false){
this.showLabelsCbx.setValue(false)
}else{
this.showLabelsCbx.setValue(true)
}
if(config.popup){
html.removeClass(this.removePopupBtn, 'disabled');
}
Expand Down Expand Up @@ -159,6 +164,7 @@ define(
name: this.layerTitle.get('value'),
opacity: this.layerAlpha.getAlpha(),
visible: this.isVisible.getValue(),
showLabels: this.showLabelsCbx.getValue(),
popup: this.config.popup,
autorefresh: this.autoRefresh.get('value'),
mode: this.flMode.get('value')
Expand Down
3 changes: 2 additions & 1 deletion setting/nls/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ define({
longMonthYear: "December 1997",
shortMonthYear: "Dec 1997",
year: "1997",
usethousandssep: "Use 1000 separator"
usethousandssep: "Use 1000 separator",
showLabels: "Show Labels?"
}),
"ar": 0,
"cs": 0,
Expand Down

0 comments on commit 2542496

Please sign in to comment.