Snippets
Created by
Piotr Szrajber
last modified
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | /**
* Updatable Styled Query
*
* This example adds a toolbar button which creates an updatable styled query or updates it
* if it is already created. Each update modifies query's filter and its style.
* Query legend item can be saved in the workspace (explicitly in the user interface or from
* code using $GP.user.workspaces)
*
* Try with http://demo.hexagongeospatial.com/communityportal/Examples.aspx?gpw=85da87cf-2a3a-47cf-b69e-7cf5372421e8
*
* Please note that:
* - this link may soon expire
* - the code below must be pasted manually in the javascript console
*
* 2017-03-22 Piotr Szrajber <piotr.szrajber@hexagongeospatial.com>
*/
var queryName = "Updatable Styled Query",
queryIndex = 0,
featureClassId = "{http://www.intergraph.com/geomedia/gml}OM_USA_STATES",
serviceUrl = "http://demo.hexagongeospatial.com/GWM_WFS_NonTransactional/service.svc/get",
scenes = [{
title: "First Scene",
filters: [{
operator: "OR",
operands: [{
operator: "=",
operands: ["{http://www.intergraph.com/geomedia/gml}STATE_NAME", "Washington"]
}, {
operator: "=",
operands: ["{http://www.intergraph.com/geomedia/gml}STATE_NAME", "Ohio"]
}, {
operator: "=",
operands: ["{http://www.intergraph.com/geomedia/gml}STATE_NAME", "California"]
}]
}],
style: {
styles: [{
type: "SimpleLineStyle",
color: "#ff0000",
size: 3
}, {
type: "SimpleFillStyle",
color: "#00cc00",
translucency: 0.2
}]
}
}, {
title: "Second Scene",
filters: [{
operator: "OR",
operands: [{
operator: "=",
operands: ["{http://www.intergraph.com/geomedia/gml}STATE_NAME", "Texas"]
}, {
operator: "=",
operands: ["{http://www.intergraph.com/geomedia/gml}STATE_NAME", "Utah"]
}, {
operator: "=",
operands: ["{http://www.intergraph.com/geomedia/gml}STATE_NAME", "Arizona"]
}]
}],
style: {
styles: [{
type: "SimpleLineStyle",
color: "#00ff00",
size: 5
}, {
type: "SimpleFillStyle",
color: "#cc0000",
translucency: 0.2
}]
}
}, {
title: "Third Scene",
filters: [{
operator: "OR",
operands: [{
operator: "=",
operands: ["{http://www.intergraph.com/geomedia/gml}STATE_NAME", "Florida"]
}, {
operator: "=",
operands: ["{http://www.intergraph.com/geomedia/gml}STATE_NAME", "Georgia"]
}]
}],
style: {
styles: [{
type: "SimpleLineStyle",
color: "#0000ff",
size: 3
}, {
type: "SimpleFillStyle",
color: "#0000cc",
translucency: 0.2
}]
}
}];
function executeQuery(scene, callback, errback) {
$GP.queries.add({
featureClassId: featureClassId,
url: serviceUrl,
definitionName: "WFS",
queryName: queryName,
addToLegend: false,
filters: scene.filters,
style: new Intergraph.WebSolutions.Core.WebClient.Platform.Style.AreaStyle(null, scene.style)
}, callback, errback);
}
function executeNextQuery(b) {
executeQuery(scenes[queryIndex++ % 3], function(result) {
if (result.updated) {
$GP.ui.info("Analysis updated #" + (queryIndex + 1));
return;
} else {
$GP.ui.info("Analysis created!");
}
$GP.queries.find({
analysisId: result.analysisId,
}, function(result2) {
result2.analysis.addToLegend(function() {
$GP.legend.find({
name: queryName
}, function(ret) {
ret.legendItems[0].fitLayer();
});
});
});
}, function() {
$GP.ui.info("Something went wrong");
});
}
$GP.ui.toolbar.add({
categoryIndex: 0,
xtype: "tbbutton",
text: "Update query",
handler: executeNextQuery
});
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.