|
DOC
|
@LixinHuang This widget has no such feature that will auto zoom to the graphic when you hover over a search result...
... View more
05-13-2021
05:42 AM
|
0
|
0
|
28719
|
|
DOC
|
@AdamGebhart , So in the other app you must have changed the "Disable All Layers Choice" in the widgets general setting then most likely.
... View more
05-12-2021
12:04 PM
|
0
|
0
|
20852
|
|
POST
|
@ChristopheS this is a timing issue. Using a settimeout will fix this. if (graphic.id == "g1" || graphic.id == "g2") {
sketchObject.cancel();
sketchObject.layer = graphicsLayer;
setTimeout(()=>{
sketchObject.update(graphic);
}, 400);
} else if (graphic.id == "gA" || graphic.id == "gB") {
sketchObject.cancel();
sketchObject.layer = graphicsLayer2;
setTimeout(()=>{
sketchObject.update(graphic);
}, 400);
}
... View more
05-12-2021
09:29 AM
|
0
|
1
|
3632
|
|
POST
|
@shilpakaramar Here is that sample updated with changes commented in the code: <!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Add Shapefile</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.36/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/fileupload.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.36/esri/css/esri.css">
<script src="https://js.arcgis.com/3.36/"></script>
<script>
var map;
require([
"esri/config",
"esri/InfoTemplate",
"esri/map",
"esri/request",
"esri/geometry/scaleUtils",
"esri/layers/FeatureLayer",
"esri/renderers/SimpleRenderer",
"esri/symbols/PictureMarkerSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
//Added modules
"esri/symbols/TextSymbol",
"esri/layers/LabelClass",
//end add modules
"dojo/dom",
"dojo/json",
"dojo/on",
"dojo/parser",
"dojo/sniff",
"dojo/_base/array",
"esri/Color",
"dojo/_base/lang",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dojo/domReady!"
],
function (
esriConfig, InfoTemplate, Map, request, scaleUtils, FeatureLayer,
SimpleRenderer, PictureMarkerSymbol, SimpleFillSymbol, SimpleLineSymbol,
TextSymbol, LabelClass,
dom, JSON, on, parser, sniff, arrayUtils, Color, lang
) {
parser.parse();
var portalUrl = "https://www.arcgis.com";
esriConfig.defaults.io.proxyUrl = "/proxy/";
on(dom.byId("uploadForm"), "change", function (event) {
var fileName = event.target.value.toLowerCase();
if (sniff("ie")) { //filename is full path in IE so extract the file name
var arr = fileName.split("\\");
fileName = arr[arr.length - 1];
}
if (fileName.indexOf(".zip") !== -1) {//is file a zip - if not notify user
generateFeatureCollection(fileName);
}
else {
dom.byId('upload-status').innerHTML = '<p style="color:red">Add shapefile as .zip file</p>';
}
});
map = new Map("mapCanvas", {
basemap: "gray-vector",
center: [-41.647, 36.41],
zoom: 2,
slider: false,
//Set the map to show labels
showLabels : true //very important that this must be set to true!
});
function generateFeatureCollection (fileName) {
var name = fileName.split(".");
//Chrome and IE add c:\fakepath to the value - we need to remove it
//See this link for more info: http://davidwalsh.name/fakepath
name = name[0].replace("c:\\fakepath\\", "");
dom.byId('upload-status').innerHTML = '<b>Loading… </b>' + name;
//Define the input params for generate see the rest doc for details
//http://www.arcgis.com/apidocs/rest/index.html?generate.html
var params = {
'name': name,
'targetSR': map.spatialReference,
'maxRecordCount': 1000,
'enforceInputFileSizeLimit': true,
'enforceOutputJsonSizeLimit': true
};
//generalize features for display Here we generalize at 1:40,000 which is approx 10 meters
//This should work well when using web mercator.
var extent = scaleUtils.getExtentForScale(map, 40000);
var resolution = extent.getWidth() / map.width;
params.generalize = true;
params.maxAllowableOffset = resolution;
params.reducePrecision = true;
params.numberOfDigitsAfterDecimal = 0;
var myContent = {
'filetype': 'shapefile',
'publishParameters': JSON.stringify(params),
'f': 'json',
'callback.html': 'textarea'
};
//use the rest generate operation to generate a feature collection from the zipped shapefile
request({
url: portalUrl + '/sharing/rest/content/features/generate',
content: myContent,
form: dom.byId('uploadForm'),
handleAs: 'json',
load: lang.hitch(this, function (response) {
if (response.error) {
errorHandler(response.error);
return;
}
var layerName = response.featureCollection.layers[0].layerDefinition.name;
dom.byId('upload-status').innerHTML = '<b>Loaded: </b>' + layerName;
addShapefileToMap(response.featureCollection);
}),
error: lang.hitch(this, errorHandler)
});
}
function errorHandler (error) {
dom.byId('upload-status').innerHTML =
"<p style='color:red'>" + error.message + "</p>";
}
function addShapefileToMap (featureCollection) {
//add the shapefile to the map and zoom to the feature collection extent
//If you want to persist the feature collection when you reload browser you could store the collection in
//local storage by serializing the layer using featureLayer.toJson() see the 'Feature Collection in Local Storage' sample
//for an example of how to work with local storage.
var fullExtent;
var layers = [];
arrayUtils.forEach(featureCollection.layers, function (layer) {
var infoTemplate = new InfoTemplate("Details", "${*}");
var featureLayer = new FeatureLayer(layer, {
infoTemplate: infoTemplate,
outFields: ["*"]
});
//associate the feature with the popup on click to enable highlight and zoom to
featureLayer.on('click', function (event) {
map.infoWindow.setFeatures([event.graphic]);
});
//Start code to set labels
// create a text symbol to define the style of labels
var sColor = new Color("#666");
var sLabel = new TextSymbol().setColor(sColor);
sLabel.font.setSize("14pt");
sLabel.font.setFamily("arial");
//this is the very least of what should be set within the JSON
var json = {
"labelExpressionInfo": {"value": "{YourDesiredFieldName}"}
};
//create instance of LabelClass (note: multiple LabelClasses can be passed in as an array)
var labelClass = new LabelClass(json);
labelClass.symbol = sLabel; // symbol also can be set in LabelClass' json
featureLayer.setLabelingInfo([ labelClass ]);
//end changes
//change default symbol if desired. Comment this out and the layer will draw with the default symbology
changeRenderer(featureLayer);
fullExtent = fullExtent ?
fullExtent.union(featureLayer.fullExtent) : featureLayer.fullExtent;
layers.push(featureLayer);
});
map.addLayers(layers);
map.setExtent(fullExtent.expand(1.25), true);
dom.byId('upload-status').innerHTML = "";
}
function changeRenderer (layer) {
//change the default symbol for the feature collection for polygons and points
var symbol = null;
switch (layer.geometryType) {
case 'esriGeometryPoint':
symbol = new PictureMarkerSymbol({
'angle': 0,
'xoffset': 0,
'yoffset': 0,
'type': 'esriPMS',
'url': 'https://static.arcgis.com/images/Symbols/Shapes/BluePin1LargeB.png',
'contentType': 'image/png',
'width': 20,
'height': 20
});
break;
case 'esriGeometryPolygon':
symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([112, 112, 112]), 1), new Color([136, 136, 136, 0.25]));
break;
}
if (symbol) {
layer.setRenderer(new SimpleRenderer(symbol));
}
}
});
</script>
</head>
<body class="claro">
<div id="mainWindow" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline',gutters:false" style="width:100%; height:100%;">
<div data-dojo-type="dijit/layout/ContentPane" id="rightPane" data-dojo-props="region:'right'">
<div style='padding-left:4px;'>
<p>
Add a zipped shapefile to the map.</p><p>Visit the
<a target='_blank' href="https://doc.arcgis.com/en/arcgis-online/reference/shapefiles.htm">Shapefiles</a> help topic for information and limitations.</p>
<form enctype="multipart/form-data" method="post" id="uploadForm">
<div class="field">
<label class="file-upload">
<span><strong>Add File</strong></span>
<input type="file" name="file" id="inFile" />
</label>
</div>
</form>
<span class="file-upload-status" style="opacity:1;" id="upload-status"></span>
<div id="fileInfo"> </div>
</div>
</div>
<div id="mapCanvas" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'"></div>
</div>
</body>
</html>
... View more
05-12-2021
08:07 AM
|
0
|
1
|
4880
|
|
DOC
|
@RaymondWang , If I understand your question correctly then what you need to do if complete your widget configuration (as you have done) and then copy the widgets config_eBookmark.json (i.e. location [WAB install folder]\server\apps\[app#]\configs\eBookmark\config_eBookmark.json). Then rename it config.json when you paste it into the [WAB install folder]\client\stemapp\widgets\eBookmark folder. Now any new app you create will have all the bookmarks you configured earlier. If I have misunderstood the question then let me know.
... View more
05-12-2021
07:36 AM
|
0
|
0
|
6680
|
|
DOC
|
@AdamGebhart , The option "Only These" will not change the UI's display of "All Layers" in the drop down (if that is what you are expecting). It will change the behavior of the "All Layers" to be only all configured layers. I have not see the icon thing you mentioned, but I have not tested 2.19 yet either.
... View more
05-12-2021
07:26 AM
|
0
|
0
|
20873
|
|
DOC
|
@AnnaStam, That is the default behavior when the locator does not provide a address. This widget is not been designed or tested to work with POI locators from Pro. I could possibly provide to code change guidance if your locator is public for me to access and test against.
... View more
05-05-2021
06:21 AM
|
0
|
0
|
11721
|
|
POST
|
James, See this thread: https://community.esri.com/t5/web-appbuilder-custom-widgets/labels-work-in-wab-de-but-not-in-deployed-site/m-p/822263#M7507
... View more
04-29-2021
11:17 AM
|
1
|
1
|
1303
|
|
POST
|
@PhilLarkin1 Sure this is what I got working for closing the widget (i.e. the widget closing itself from the code) this.props.dispatch(appActions.closeWidget(this.props.id)); and for messaging other widgets of some data: this.props.dispatch(appActions.widgetStatePropChange(this.props.id, 'pSearchData', cTextElements));
... View more
04-28-2021
12:33 PM
|
2
|
1
|
6968
|
|
DOC
|
@LixinHuang I have tried to get tabbing working properly in this widget without any success.
... View more
04-28-2021
10:48 AM
|
0
|
0
|
28888
|
|
DOC
|
@PetersonPierre-Louis In the Widget.js find the displayPopupContent and make this change: if(this.popupContent){
this.popupContent.set("content", content);
//Added code
var evt = new MouseEvent("click", {
bubbles: false,
cancelable: true,
view: window
});
this.zoomToClicked(evt);
//end Add
}
... View more
04-28-2021
05:52 AM
|
0
|
0
|
16351
|
|
POST
|
@fahadrasheed You should look at this thread then. https://community.esri.com/t5/web-appbuilder-custom-widgets/custom-link-in-local-data-popup-click-on-the-map/m-p/791733#M4217
... View more
04-28-2021
05:21 AM
|
1
|
0
|
2420
|
|
DOC
|
@PetersonPierre-Louis The popup panel widget never had an auto zoom to selected feature functionality. Are you asking how to change the code to add that?
... View more
04-27-2021
06:40 AM
|
0
|
0
|
16379
|
|
POST
|
@fahadrasheed A feature action is the proper way forward.
... View more
04-27-2021
06:24 AM
|
0
|
0
|
2424
|
|
POST
|
@fahadrasheed OK. In 2.16 you would add a popup action. Here is the help doc link for that. https://developers.arcgis.com/web-appbuilder/guide/create-a-feature-action-in-your-widget.htm
... View more
04-26-2021
06:04 AM
|
0
|
0
|
2428
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-14-2020 11:36 AM | |
| 17 | 05-17-2021 01:51 PM | |
| 1 | 07-06-2020 05:32 AM | |
| 1 | 07-10-2018 05:49 AM | |
| 9 | 01-28-2022 10:58 AM |
| Online Status |
Offline
|
| Date Last Visited |
06-08-2026
06:27 AM
|