POST
|
Thank you Egge for your advice, I am not sure if the dialog that select and add the shapefile is working fine, when I tried to add the js tool thats written above, the toolbar is stopped working, may you please have a look on the above js code? or may you please advice me how to check my code if it is written correctly? software? tool?... define(["dojo/dom", "dojo/json", "dojo/on", "dojo/parser", "dojo/sniff", "dojo/_base/array", "esri/Color", "dojo/domReady!", "esri/config", "esri/InfoTemplate",
"esri/request", "esri/geometry/scaleUtils", "esri/layers/FeatureLayer", "esri/renderers/SimpleRenderer", "esri/symbols/PictureMarkerSymbol", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol"
],
function (
esriConfig, InfoTemplate, Map, request, scaleUtils, FeatureLayer,
SimpleRenderer, PictureMarkerSymbol, SimpleFillSymbol, SimpleLineSymbol,
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>';
}
});
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
});
//associate the feature with the popup on click to enable highlight and zoom to
featureLayer.on('click', function (event) {
map.infoWindow.setFeatures([event.graphic]);
});
//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));
}
}
function selectChild() {
proxy.layout.toggleRegion({ region: "trailing", expanded: true });
proxy.layout.selectChild(displayPanel);
};
this.init = function() {
var dfd = proxy.utility.deferred();
dfd.resolve();
return dfd;
};
this.show = function() {
if (!initialized) {
//We will create the UI here before showing it
initialized = true;
var uiConfig = initUI();
displayPanel = proxy.layout.createTrailingPanel(uiConfig);
selectChild();
} else {
//The UI is already created so just show it
selectChild();
}
};
});
... View more
05-01-2020
03:23 PM
|
4
|
1
|
1373
|
POST
|
Thank you Egge for your reply, yes I used the code here, but I want to edit it to match the one attached in order to work with our Cityworks map, Do you have any idea what is the best practice to do this? I tried to edit it but ends with an error, and unfortunately I do not have enough experince in javascript. Thank you in advance
... View more
04-20-2020
12:04 PM
|
6
|
3
|
1373
|
POST
|
How to customize a map tool so as to be able to add a shapefile then create an object and zoom to it? We tried to customize a map tool so as to be able to add a shapefile then create an object and zoom to it to use this tool in the cityworks map and zoom to it, but seems that we missing something, I highly appreciate if someone can have a look on this: define(["dojo/dom", "dojo/json", "dojo/on", "dojo/parser", "dojo/sniff", "dojo/_base/array", "esri/Color", "dojo/domReady!", "esri/config", "esri/InfoTemplate",
"esri/request", "esri/geometry/scaleUtils", "esri/layers/FeatureLayer", "esri/renderers/SimpleRenderer", "esri/symbols/PictureMarkerSymbol", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol"
],
function (
esriConfig, InfoTemplate, Map, request, scaleUtils, FeatureLayer,
SimpleRenderer, PictureMarkerSymbol, SimpleFillSymbol, SimpleLineSymbol,
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>';
}
});
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
});
//associate the feature with the popup on click to enable highlight and zoom to
featureLayer.on('click', function (event) {
map.infoWindow.setFeatures([event.graphic]);
});
//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));
}
}
function selectChild() {
proxy.layout.toggleRegion({ region: "trailing", expanded: true });
proxy.layout.selectChild(displayPanel);
};
this.init = function() {
var dfd = proxy.utility.deferred();
dfd.resolve();
return dfd;
};
this.show = function() {
if (!initialized) {
//We will create the UI here before showing it
initialized = true;
var uiConfig = initUI();
displayPanel = proxy.layout.createTrailingPanel(uiConfig);
selectChild();
} else {
//The UI is already created so just show it
selectChild();
}
};
});
It should be written the same way as shown in the attached file (the attached file is how to add xy to cityworks map, and it works perfectly) Highly appreciate your effort. Thank you in advance
... View more
04-18-2020
02:33 PM
|
6
|
5
|
1687
|
POST
|
Displaying DWG file over the ArcGIS JS map viewer We have an ArcGIS java script web application. We need to add a functionality to allow the user to upload the Drawing file (DWG) from the client browser and Zoom into the drawing file location and display the drawing. It should be on the fly and it should maintain the symbology. For example, in Geocortex, we managed to develop a tool that can import and display AutoCAD file (.dwg) in the Web using FME server Any suggestions?
... View more
04-15-2020
02:06 PM
|
4
|
5
|
4713
|
POST
|
Thanl you Lefteris and Abdullah, It works fine with me but after publishing the georoprossing with the warning shown in the screen, and I foud out that I should draw an AOI before running the geoprossing the tool, without this the publishing will end with staging failed error, but why I should drwa the AOI?
... View more
04-09-2020
08:55 AM
|
5
|
0
|
793
|
POST
|
You need to repair the path for the overviews and set it to read from the original path and not from the shared folder, this will solve the issue!! But I couldn’t figure out why it fails to read it from the shared folder!! Also, you need to close the Acgis pro before publishing the map, and then open in and make sure that the aprx is opened from the network path and not the D drive.
... View more
04-08-2020
02:44 PM
|
4
|
3
|
1676
|
POST
|
Thank you Robert, it works like a charm. I tried the two options to add the layer as a base map and it works fine. the first options as shown below to add the tile map from my content Second option: from WEB and the coordenate will expanded by default, but why is the default unit is in feet and not meter?? the good thing that I switch it to metric and it works fine: Thank you
... View more
04-06-2020
01:47 PM
|
9
|
0
|
897
|
POST
|
Thank you for your reply, the "Raster Format" parameter actually used in your case. I do not think that the issue is related to the consolidate, since I tried to publish the tool without clicking the analyze option with no error, but when trying to add this tool to the WAB it does not work, do you have any idea?, but when try to publishing it using arcmap and adding them to WAB it works fine, it seems that their is a specific settings at the level of arcpro...
... View more
04-06-2020
01:26 PM
|
5
|
0
|
2090
|
POST
|
I noticed that the Arc pro will publish the tool if I didn't click the analyze option without any error, but when trying to add this tool to the WAB it does not work, do you have the same behavior?
... View more
04-06-2020
01:18 PM
|
7
|
5
|
2090
|
POST
|
I do the same and unfortunate, it didn't solve my issue!
... View more
04-05-2020
02:18 PM
|
7
|
6
|
2090
|
POST
|
Thank you for your reply, as I mentioned before that I couldn't remove it since the remove button is gray, do you have any idea how to remove it?
... View more
04-05-2020
01:08 PM
|
7
|
2
|
897
|
POST
|
Thank you for your reply, I tried to add a base map with 28191 WKID, and the issue persist to exist. and unfortunately I couldn't delete the "World Hillshade" base map, and the new base map does not appear on the WAB map despite the fact that it is appeared in the map itself, and the “coordinates” does not expanded by default. please see the below:
... View more
04-04-2020
12:28 PM
|
7
|
4
|
897
|
POST
|
regarding the path, I created a new folder on the D which name is e as shown:
... View more
03-29-2020
01:07 PM
|
8
|
5
|
3926
|
POST
|
Hi again, I am not sure if I am doing something wrong while running the extract data task, and also I noted that when trying to click on the publish button to publish the tool, it is written that (federated server is not available), taking into considerations that this message only appears when publishing a geoprossing tool, please have a look in the screen shots below:
... View more
03-29-2020
01:03 PM
|
6
|
0
|
3926
|
Title | Kudos | Posted |
---|---|---|
2 | 06-14-2023 05:01 AM | |
1 | 09-05-2017 02:58 AM | |
1 | 01-19-2020 11:54 PM | |
1 | 08-25-2018 11:29 PM | |
2 | 08-27-2020 01:07 AM |
Online Status |
Offline
|
Date Last Visited |
07-01-2024
08:15 PM
|