Skip to content

Commit

Permalink
First release of DrawMeasureWidget compatible with Webapp Builder 1.3…
Browse files Browse the repository at this point in the history
…. Dependencies folder updated with CustomUtils folder. README.md has the

required info
  • Loading branch information
arunsebastian committed Feb 26, 2016
1 parent 018037d commit 18fe312
Show file tree
Hide file tree
Showing 14 changed files with 1,402 additions and 194 deletions.
960 changes: 960 additions & 0 deletions dependencies/CustomUtils/SimpleTable.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion dependencies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ This folder provides top level access to any widget dependencies. This may inclu
- Server Object Extension Source Code
- Python Scripts
- Geoprocessing Models
- SQL Scripts
- SQL Scripts

Important Notes

1. "CustomUtils" folder contains any utility,library files which may be required for the widgets delivered.This is a frame-work level utility folder which has to reside in
<WebApp Builder 1.3 path>/client/stemapp/jimu.js/

2. Content of SymbolsInfo folder has to be copied to <WebApp Builder 1.3 path>/client/stemapp/jimu.js/dijit/SymbolsInfo path and use the file name ("picturemarker") to configure
the Picturemarker configuration section of DrawMeasureWidget.
55 changes: 43 additions & 12 deletions src/Buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ define(
},
_mousetip: null,
_isActive: false,
constructor: function (container, map, layer, config) {
constructor: function (container, map, layer,nls, config) {
this.domNode = domConstruct.create("div", {
"title": "Buffer",
"data-geotype": "BUFFER",
Expand All @@ -62,6 +62,7 @@ define(
this._setMap(map);
this._setLayer(layer);
this._setConfig(config);
this._setNls(nls);
this._createMousetip();
},
_setMap: function (map) {
Expand All @@ -73,6 +74,9 @@ define(
_setConfig: function (config) {
this.config = config;
},
_setNls:function(nls){
this.nls = nls;
},
setParams: function (a, b, c) {
this._distance = a;
this._unit = b;
Expand All @@ -82,26 +86,51 @@ define(
var me = this;
this._isActive = true;
this._activateMouseTip();
domClass.add(this.domNode, "selected");
domClass.add(this.domNode, "jimu-state-active");
if (!this._clickHandle) {
this._clickHandle = connect.connect(this._map, "onClick", function (evt) {
var extentGeom = me.pointToExtent(evt.mapPoint, me._map);
var sourceGraphicIndex;
var filteredGraphics = array.filter(me._layer.graphics, function (graphic, index) {
return extentGeom.contains(graphic.geometry) || extentGeom.intersects(graphic.geometry);
if (extentGeom.contains(graphic.geometry) || extentGeom.intersects(graphic.geometry)) {
sourceGraphicIndex = index;
return true;
}
});
if (filteredGraphics.length > 0) {
me.doBuffer(filteredGraphics[0]).then(function (bufferGeom) {
var bufferGraphic = new Graphic(bufferGeom, me._symbology, { uniqueId: new Date().getTime() });
var sourceGraphic = filteredGraphics[0];
me.doBuffer(sourceGraphic).then(function (bufferGeom) {
var bufferGraphic = new Graphic(bufferGeom, me._symbology, { uniqueId: new Date().getTime(),pariId:"Pari" });
me._layer.add(bufferGraphic);
if (bufferGraphic && bufferGraphic.getDojoShape()) {
if (me._distance <= 0) {
bufferGraphic.getDojoShape().moveToFront();
} else {
bufferGraphic.getDojoShape().moveToBack();
//swapping the positions of orginal and buffer in the layer.graphics array
//so that the smaller one comes on top when imported from a mpk file
var sourceAttributes = lang.clone(sourceGraphic.attributes);
var sourceGeometry = lang.clone(sourceGraphic.geometry);
var sourceSymbol = lang.clone(sourceGraphic.symbol);

var bufferAttributes = lang.clone(bufferGraphic.attributes);
var buffereGeometry = lang.clone(bufferGraphic.geometry);
var bufferSymbol = lang.clone(bufferGraphic.symbol);


bufferGraphic.setGeometry(sourceGeometry);
bufferGraphic.setAttributes(sourceAttributes);
bufferGraphic.setSymbol(sourceSymbol);


sourceGraphic.setGeometry(buffereGeometry);
sourceGraphic.setAttributes(bufferAttributes);
sourceGraphic.setSymbol(bufferSymbol);

//sourceGraphic and bufferGraphic are now swapped by now in terms of geometry/attributes
sourceGraphic.getDojoShape().moveToBack();
}
}
topic.publish("BUFFER_GRAPHIC_ADDED", bufferGraphic);

}, function () {
me._showErrorMessage();
})
Expand All @@ -114,7 +143,7 @@ define(
deactivate: function () {
this._isActive = false;
this._deactivateTooltip();
domClass.remove(this.domNode, "selected");
domClass.remove(this.domNode, "jimu-state-active");
if (this._clickHandle) {
connect.disconnect(this._clickHandle);
this._clickHandle = null;
Expand All @@ -141,8 +170,8 @@ define(
return extent;
},
_createMousetip: function () {
if (this.config.mousetip) {
this._mousetip = domConstruct.create("div", { "class": "mousetip", "innerHTML": this.config.mousetip }, this._map.container);
if (this.nls.mousetip) {
this._mousetip = domConstruct.create("div", { "class": "mousetip", "innerHTML": this.nls.mousetip }, this._map.container);
domStyle.set(this._mousetip, {
"position": "fixed",
"display": "none"
Expand Down Expand Up @@ -187,7 +216,9 @@ define(
connect.disconnect(this._mousetipHandle.mouseMove);
this._mousetipHandle.mouseMove = null;
}
this._mousetip.style.display = "none";
if (this._mousetip) {
this._mousetip.style.display = "none";
}
},
doBuffer: function (graphic) {
var me = this;
Expand Down Expand Up @@ -216,7 +247,7 @@ define(
},
_showErrorMessage: function () {
var popup = new Message({
message: this.config.invalidRequestMessage,
message: this.nls.invalidRequestMessage,
buttons: [{
label: "OK",
onClick: lang.hitch(this, function () {
Expand Down
33 changes: 6 additions & 27 deletions src/DynamicMeasure.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ define(
calculateMeasurement([drawToolbar._tGraphic,drawToolbar._customGraphic]);
}
}

}
}));
aspect.after(drawToolbar, "_onClickHandler", lang.hitch(this, function (orginalFn) {
Expand Down Expand Up @@ -232,18 +231,20 @@ define(
var distanceAbbr = this._distanceAbbr;
if (this._tool._tooltip && type === "distance") {
this._tool._tooltip.style.display = "";
this._tool._tooltip.style.width = "120px";
this._tool._tooltip.style.height = "40px";
this._tool._tooltip.style.minWidth = "120px";
this._tool._tooltip.style.minHeight = "40px";
this._tool._tooltip.style.height = "auto";
this._tool._tooltip.style.width = "auto";
if (measurements.length == 1) {
instructionText = "Let go to finish.<br>";
} else if (measurements.length == 2 ) {
instructionText = "Double-click to finish.<br>";
instructionText += "Click to continue drawing.<br>";
this._tool._tooltip.style.width = "145px";
}
instructionText += "Distance <b>: " + measurements[0] + distanceAbbr+ "</b><br>";
instructionText += "Distance <b>: " + measurements[0] + distanceAbbr+ "</b>";
if (measurements.length == 2) {
instructionText += "Total <b>: " + measurements[1] +distanceAbbr+ "</b>";
instructionText += "<br> Total <b>: " + measurements[1] + distanceAbbr + "</b>";
this._tool._tooltip.style.height = "85px";
}
this._tool._tooltip.innerHTML = instructionText;
Expand All @@ -254,28 +255,6 @@ define(
domClass.remove(this._tool._tooltip, "measure-loading");
}
},
_updateMeasurementInTootip: function (measureObj) {
if (measureObj.type === "length") {
var prefix = measureObj.message;
if (measureObj.singleSegment) {
var msg = prefix+"Distance: <b>"+ measureObj.total;
this._tool._tooltip.innerHTML = msg + "</b>";
this._tool._tooltip.style.width = "165px";
} else {

var msg = prefix + "Distance: <b>";
msg = msg + measureObj.intermediate;

msg += "</b> <br> Total: <b>";
msg += measureObj.total;

this._tool._tooltip.innerHTML = msg + "</b>";
this._tool._tooltip.style.width = "auto";
this._tool._tooltip.style.padding = "10px;";

}
}
},
_updateTooltipPosition:function(c){
this._tool._updateTooltip(c);
}
Expand Down
13 changes: 5 additions & 8 deletions src/ExportUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define(
"dojo/topic",
'dojo/Deferred',
'esri/tasks/PrintTask'

], function (
declare,
array,
Expand Down Expand Up @@ -45,7 +45,8 @@ define(


var printTask = new PrintTask();
var w = printTask._getPrintDefinition(map);
// gbs.sjh - second paramater is required at sjapi v3.14, is a PrintTemplate object I think. This is quick fix.
var w = printTask._getPrintDefinition(map, {preserveScale: false});

var operationalLayers = this.getOperationalLayers(w,map);
var mapOptions = w.mapOptions;
Expand All @@ -71,7 +72,7 @@ define(
feat.symbol.url = baseUrl + feat.symbol.url;
}
}
// text symbol, remove all attributes
// text symbol, remove all attributes
if (feat.symbol.type === "esriTS") {
feat.attributes = {};
}
Expand All @@ -83,7 +84,7 @@ define(
}
});

webmapJson = this.stringify(w);
webmapJson = this.stringify(w);

return webmapJson;
},
Expand All @@ -106,7 +107,3 @@ define(

return ExportUtil;
});




Loading

0 comments on commit 18fe312

Please sign in to comment.