POST
|
I want to build a custom tool to help me quickly search and visualize layers from my geodatabase in a web map. I know I can use Arcmap or Arcgis Pro to search and visualize these layers, but I really think it's too slow to open those tools just to search and check a layer, without editing. Also, the search tool in those softwares don't work the way I would expect. I'm wondering if there is a way to combine arcgis javascript API and SDE.ST_ASTEXT() database function to show features stored in my geodatabase in a web map. Does arcgis javascript API recognize the return of SDE.ST_ASTEXT()? Can anyone point me in the right direction to solve this?
... View more
08-21-2021
02:30 PM
|
0
|
0
|
1214
|
POST
|
This is still a question in 2021. I had the same issue today when using SDE.ST_POINT(). Turns out that the problem is related to NLS_NUMERIC_CHARACTERS config. SDE.ST_POINT will throw "Shape has too many parts" if NLS_NUMERIC_CHARACTERS =",.". This is probably the case for sde.ST_GeomFromText(). To solve the issue, use dbms_session.set_nls() in the first line of the stored procedure or function as follows: create or replace PACKAGE BODY TEST_PACK AS procedure test as begin dbms_session.set_nls('NLS_NUMERIC_CHARACTERS', '".,"'); insert into table_evw(shape) values (sde.ST_GeomFromText('point ('|| -73.16 || ' ' || 6.78 || ')', 4686)); end test; Solution found here: StackOverflow
... View more
02-25-2021
11:43 AM
|
0
|
0
|
642
|
POST
|
It seems to me that the order that the widgets are been created is causing the problem. Probably Search widget is been created before the other widgets. If this is the case, it seems that this.fetchDataByName('Query') will not find the widget Query because it doesn't exists yet. Maybe you should try to use dojo/topic module to solve this problem. You'll probably do something like this: //Search/Widget.js
startup: function() {
this.inherited(arguments);
topic.subscribe('query', lang.hitch(this, this.whenQueryPublishesDo));
//...
},
whenQueryPublishesDo: function(data){
//...process data
console.log(data.result)
}, //Query/Widget.js
define([
'dojo/topic',
//....
]), function(
topic,
//...
)
//...
someMethod: function() {
var data = {
result : {
//...
}
};
topic.publish('query', data);
},
... View more
08-13-2020
04:26 PM
|
0
|
1
|
1019
|
POST
|
Hi Michael. 1. Yes, regular javascript promises will work with lang.hitch. Here is a sample code: define([
'dojo/_base/declare',
'dojo/_base/lang',
'jimu/BaseWidget'
], function (
declare,
lang,
BaseWidget
) {
return declare([BaseWidget], {
onOpen: function(){
var shouldFail = false;
this.fetchMessage(shouldFail).then(lang.hitch(this, this.processMessage))
.then(lang.hitch(this, this.showMessage))
.catch(lang.hitch(this, this.showMessage));
},
fetchMessage: function (shouldFail) {
var milisseconds = 2000;
return new Promise((resolve, reject) => {
setTimeout(function () {
if (shouldFail) {
reject('Error message');
} else {
resolve('Success message');
}
}, milisseconds);
});
},
processMessage: function (message) {
var milisseconds = 2000;
return new Promise((resolve, reject) => {
setTimeout(function () {
var processedData = "Processed " + message;
resolve(processedData);
}, milisseconds);
});
},
showMessage:function(message){
alert(message);
}
});
}); 2. dojo/Deferred is a dojo module that implements Promises. I've noticed there is some diference between Deferred and regular javascript Promises, but the intent is the same for both of them. It seems better to use dojo/Deferred, because you can guarantee that this module will work in many browsers that dojo supports. Regular javascript Promises won't work in some browser versions, Internet Explorer 11 for example (check more here: https://caniuse.com/#search=Promise). Also, many, if not all, jimu modules implemented by ESRI use dojo/Deferred. By choosing it, you will prevent using 2 different modules that do the same thing, this reduces the amount of complexity to maintain your code and to understand ESRI code. Here is the documentation for the interface of dojo/promise: https://dojotoolkit.org/reference-guide/1.10/dojo/promise/Promise.html#dojo-promise-promise.
... View more
08-12-2020
11:04 AM
|
2
|
2
|
1541
|
POST
|
Michael, if you can't get it working with lang.hitch, there is another way you can track scoping inside a class. Here is an example : define([
//...
], function (
//...
) {
var that;
return declare(null, {
someData: '',
postCreate: function () {
that = this;
that.fetchSomeData().then(that.showData)
.otherwise(that.showError);
// instead of:
// this.fetchSomeData().then(lang.hitch(this, this.showData))
/// .otherwise(lang.hitch(this, this.showError));
},
fetchSomeData: function(){
var deferred = new Deferred();
someAsyncQuery().then(function(response){
that.someData = response;
deferred.resolve(response);
}).otherwise(function(error){
deferred.reject(error);
});
return deferred.promise;
},
showData: function(response){
alert(response);
},
showError:function(error){
alert(error);
}
});
}); I think lang.hitch does the job, but it makes the code really hard to read.
... View more
08-11-2020
02:25 PM
|
3
|
1
|
1541
|
POST
|
You probably have to instantiate a proper Renderer object. From the docs (FeatureLayer | API Reference | ArcGIS API for JavaScript 3.33 😞 The layer's renderer must be of type SimpleRenderer, ClassBreaksRenderer, or UniqueValueRenderer. Here you have plain object without methods, only properties: featureLayer.renderer = {
"_cache": {
"rotationInfo": null,
"colorInfo": null,
"opacityInfo": null, It probably should be something like this : var renderer = new SimpleRenderer({ ClassBreaksRenderer, or UniqueValueRenderer.
"rotationInfo": null,
"colorInfo": null,
"opacityInfo": null,
...
});
featureLayer.setRenderer(renderer);
... View more
08-11-2020
07:33 AM
|
2
|
2
|
782
|
POST
|
Michael, same question asked here: https://community.esri.com/thread/251590-displaying-dwg-file-over-the-arcgis-js-map-viewer I've provided some steps there that may help you approach this problem.
... View more
08-07-2020
10:25 AM
|
4
|
10
|
2106
|
POST
|
Can you confirm the token is been sent to Print Service in the body of the POST request? You can verify that by opening chrome developer tools in your google chrome browser an open the headers tab to confirm the presence of this token paremeter. IdentifyManager module can be used to register the token using arcgis js api. After registering it, it should be sent with the requests you make to arcgis services. Use esriId.registerToken() function.
... View more
08-07-2020
09:55 AM
|
1
|
1
|
1201
|
POST
|
Based on your json output, and knowing it is a ArcGISDynamicMapServiceLayer, the snippet should work if you try: var layerId = 'alallomas_9075'; var operationalLayer = getWebmapOperationalLayerById(layerId); operationalLayer.getLayerObject().then(function(layerObject){ var title = 'Popup title'; var content = 'Custom description. You can use HTML here. <br> And access attribute value like this ${SOME_ATRIBUTE}'; var sublayerId = 0; if(!layerObject.infotemplates){ layerObject.infotemplates = {}; } layerObject.infotemplates[sublayerId]= { infoTemplate: new InfoTemplate(title, content); }); }) In ArcGISDynamicMapServiceLayer, infotemplates are stored in a different way. The id alallomas_9075_0 means: alallomas is the mapserver name, 9075 is (probably) a random number and 0 is the sublayerId. This is not documented, by the way....
... View more
08-06-2020
12:19 PM
|
2
|
1
|
1895
|
POST
|
Time is necessary to master any tecnology, frustration is part of the process. I have struggled with this same problem a while ago. Here is a snippet you can copy and paste in google chrome developer console to see it working. The web appbuilder application must be opened in the browser tab for you to try this. I think this part of the api is really missing some docs. LayerStructure module uses LayerInfos behind the scenes. The sample code uses LayerInfos module directly. var LayerInfos = require('jimu/LayerInfos/LayerInfos'); var InfoTemplate = require('esri/InfoTemplate'); function getWebmapOperationalLayerById (layerId) { var instance = LayerInfos.getInstanceSync(); var layerFound = null; instance.traversalLayerInfosOfWebmap(function (aLayer) { if (aLayer.id === layerId) { layerFound = aLayer; return; //get out of traversalLayerInfosOfWebmap() } }); return layerFound; } function modifyInfoTemplate( layerObject) { var title = 'Popup title'; var content = 'Custom description. You can use HTML here. <br> And access attribute value like this ${SOME_ATRIBUTE}'; layerObject.infoTemplate = new InfoTemplate(title, content); } var layerId = 'YOUR_LAYER_ID_HERE'; var operationalLayer = getWebmapOperationalLayerById(layerId); operationalLayer.getLayerObject().then(modifyInfoTemplate); It is important to use operationalLayer.getLayerObject() method (instead of accessing directly operationalLayer.layerObject), because sometimes layerObject is not loaded and will be empty. getLayerObject() will assure the object is loaded before you modify infotemplate. To find a layerId you can use _viewerMap._layers in chrome developer console to see what's in there.
... View more
08-06-2020
10:57 AM
|
1
|
3
|
1895
|
POST
|
For future reference. There is a way, but it doesn't mantain the symbology. You'll have to publish a GPServer to your Arcgis Server to make it happen. It's not possible to do this using only javascript. I've done using arcgis js api 3.x (to create a custom widget for web appbuilder) and a python GPServer. Here is how you can develop it: The python script part: 1. Create a toolbox using Arcmap (or Arcgis Pro, if you're already using it) and publish it as a GPServer. The toolbox must contain a python script using arcpy with the following instructions: 1.2 Toolbox should have 2 input parameters: one for File and the other for the geometry type. 1.3 Toolbox should have 1 output parameter. The output will be a json file to be used in arcgis js api. 1.4 Check input preconditions: 1.4.1 File extension must exist and must have .dwg extension. 1.4.2 Geometry type must exist and must be polygon, point or polyline. 1.5 Use the arcpy.FeatureClassToShapefile_conversion(pathToTheInputDWGFile, tempDirectory) to convert the DWG file to Shapefile. This is a required step. 1.6 Use arcpy.FeaturesToJSON_conversion(pathToShapeFileInTheTempDirectory, pathToResultJsonFile, "NOT_FORMATTED", "NO_Z_VALUES", "NO_M_VALUES", "NO_GEOJSON") 1.7 Use arcpy.SetParameterAsText(2, pathToResultJsonFile) to send the converted file as json to your arcgis js api. The javascript part: 2. Develop a Widget using Arcgis JS api (3.x or 4.x, it doesn't matter) with the following inputs: 2.1 - A select box containing the geometry type it is supposed to load from the DWG file: Point, Polyline or Polygon. 2.2 - Input field to add the DWG file. 2.3 - A layer name, to be added to the map. 2.4 - Query the GPServer using esriRequest module and use following code to create a featureLayer from the gpServerJsonResult: For arcgis js api 4.x, you can code something like this: var featureSet = FeatureSet.fromJSON(gpServerJsonResult); var dwgLayer = new FeatureLayer({ title: featureTitle, id: "aDwgLayer", source: featureSet.features, fields: featureSet.fields, objectIdField: featureSet.fields[0].name, spatialReference: featureSet.spatialReference, geometryType: featureSet.geometryType, renderer: yourCustomRenderer }); map.addLayer(dwgLayer); For arcgis js api 3.x, you can code something like this: var featureCollection = { layerDefinition: gpServerJsonResult, featureSet: { features: gpServerJsonResult.features, geometryType: gpServerJsonResult.geometryType } }; var dwgLayer = new FeatureLayer(featureCollection); map.addLayer(dwgLayer); You can find more ways to create the python script to convert CAD data to Arcgis shapefile here: How To: Convert selected CAD data to ArcGIS shapefile, coverage, or geodatabase feature classes using geoprocessing . However, what worked for me was arcpy.FeatureClassToShapefile_conversion tool.
... View more
08-05-2020
07:01 PM
|
5
|
4
|
3807
|
POST
|
For future references... It's 2020 and I'm having the same issue you described using graphicsUtils.graphicsExtent with a point layer. I develop using js api version 3.x. Turns out, that for some reason one feature in the array returned from the REST query is coming with the following geometry: { "geometry": { "x": "NaN", "y": "NaN", "spatialReference": ... }, "attributes": { ... } } Our users add points to this layer using Arcmap 10.5 and Arcmap 10.7 and I couldn't find out why sometimes this null geometry happens. If you query the database to view this bad registry with sqldeveloper, you will find some null data inside shape column: At least, that was what happened here. I would recomend checking the array for NaN data before using graphicsUtils.graphicsExtent to filter out bad data like this: //note that NaN here is a string var goodFeatures = features.filter(f => f.geometry.x === "NaN" || f.geometry.y === "NaN"); var extent = graphicsUtils.graphicsExtent(goodFeatures) When I set the map with a bad extent, the map simply disapear and breaks the app.
... View more
07-03-2020
09:53 AM
|
0
|
0
|
1178
|
POST
|
I've uploaded an image icon to Portal for Arcgis so that I can use it as Picture Marker Symbol in my maps. After configuring the layer symbology in map viewer to use the URL of the uploaded icon, it recognizes the image but wont show it in the map. Am I doing something wrong? Is this a valid procedure? I'm using Portal for Arcgis 10.5.1 and the icon is in PNG format.
... View more
02-20-2020
12:07 PM
|
0
|
0
|
238
|
POST
|
Maybe spatialReference of points is different from the map. return new Point({
x:point.x,
y:point.y,
spatialReference : result.SHAPE.srid
}); I had that kind of problem once when using Arcgis js api 3.x and needed to project the points before add to the map.
... View more
09-26-2019
06:27 AM
|
0
|
10
|
832
|
POST
|
A quick and dirty way of doing it, could be something like this: function configurePopupMobileToMaximize (map) { require(['dojo/aspect'], function(aspect){ aspect.after(map.infoWindow, 'onSelectionChange', function () { var feature = map.infoWindow.getSelectedFeature(); if (feature !== undefined && map.infoWindow._toggleView) { map.infoWindow._toggleView(); } }); }); } Then just call somewhere this function to configure the behaviour before the user open some popup. configurePopupMobileToMaximize(myMap); Now, this uses a "private" function _toogleView() that we probably shouldn't use directly for some reason. Also, you probably should require the aspect module somewhere else (like a define block) and not inside the function. But it works.
... View more
09-25-2019
07:31 AM
|
1
|
1
|
411
|
Title | Kudos | Posted |
---|---|---|
1 | 11-12-2018 08:15 AM | |
1 | 08-06-2020 10:57 AM | |
1 | 09-25-2019 07:31 AM | |
1 | 03-25-2019 11:12 AM | |
1 | 12-08-2017 03:36 AM |
Online Status |
Offline
|
Date Last Visited |
09-21-2021
07:41 AM
|