POST
|
I have an enterprise database with a large point feature class of locations. I have a related table (one location can have many related rows here) and I use attributes in this table to make database views for my locations. This way, users can add only locations relevant to their project to their map (using Arc Pro) without having to use definition queries (which don't work well for this use-case because of performance issues across large tables and usability/shareability limitations). I just started testing a branch versioning workflow and the archiving columns seem to have broken these views--since now each view is pulling in the whole archive of edited rows instead of the last edited row. I have reviewed this thread that poses the same question: https://community.esri.com/t5/geodatabase-questions/branch-versioning-and-sql-views/td-p/758382 and had difficulty implementing a REST query. I can't find a way to query my feature service based on its related table (ie: return rows in my point feature class that have related column=X) and add both the locations, relationship and related data to the map. I was also having trouble wrapping my head around the suggested query. It seems like to get what I want, in the related table, I'd need to do a max(last_edited_date) for each distinct foreign key from my location table. But I'm not sure how to write a query like that (or if it's even possible) Anyone have any ideas on how to get different subsets of branch versioned data from two related tables into Arc Pro as layers?
... View more
03-10-2022
12:38 PM
|
0
|
0
|
660
|
POST
|
I get an old version of the totalapis.github.io page as my top results for "esri js api" searches. I've resorted to just bookmarking: https://developers.arcgis.com/javascript/latest/api-reference/
... View more
08-27-2021
09:24 AM
|
0
|
1
|
995
|
POST
|
Check out the expand widget: https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html var print = new Print({
view: view
});
printExpand = new Expand({
expandIconClass: "esri-icon-printer",
expandTooltip: "Expand Print",
view: view,
content: print
});
view.ui.add(printExpand, "top-right"); ;
... View more
08-27-2021
09:02 AM
|
2
|
1
|
1147
|
POST
|
You can use css to hide the button in the interface: .esri-distance-measurement-2d__clear-button {
display: none;
} If you want a button to clear measurements and reset the widget, you can create a button in your interface and use some JS like: clearButton.addEventListener("click", function () {
measurement.clear();
}); where measurement is the name of your Measurement object.
... View more
08-23-2021
01:15 PM
|
0
|
0
|
708
|
POST
|
@AndyGup Thank you for the reply and advice. After reviewing Kelly's repo of the demo app I've gotten my code to compile and run on the snowpack dev server. I'm getting a few errors that I don't understand the cause of: My widget is now giving the error: Uncaught (in promise) ReferenceError: React is not defined It's coming from my widet's compiled .js file in the render method: render() {
if (!this.openGroup) {
return /* @__PURE__ */ React.createElement("div", {
class: CSS.root
}, this.renderGroups());
//in TSX:
render() {
if (!this.openGroup) {
return (<div class={CSS.root}>
{this.renderGroups()}
</div>);
} and when I run npx tsc I get two errors: [16:18:16] [@snowpack/plugin-typescript] node_modules/@types/eslint/index.d.ts(451,42): error TS2724: '".../node_modules/@types/estree/index"' has no exported member named 'ChainExpression'. Did you mean 'ThisExpression'? [16:18:16] [@snowpack/plugin-typescript] node_modules/@types/eslint/index.d.ts(474,43): error TS2694: Namespace '".../node_modules/@types/estree/index"' has no exported member 'ImportExpression'. I was previously able to resolve these tsc compile errors by removing package-lock.json and node_modules and re-running npm install, but that hasn't worked this time. Any idea what I need to do? Thank you again for your advice, I will try to transition to webpack. Snowpack's minimal config requirements are very attractive, I wanted at least to try it out.
... View more
07-26-2021
12:35 PM
|
0
|
0
|
850
|
POST
|
I'm using 4.20 api in my app with @arcgis/core. I have a custom layer manager widget I want to load and I've been using this method from the custom widget documentation, but it doesn't seem to work with ES modules. I have in my index: <script>
var locationPath = location.pathname.replace(/\/[^\/]+$/, "");
window.dojoConfig = {
packages: [
{
name: "layer-manager",
location: locationPath + "./Widgets/LayerManager/app"
}
]
};
</script>
<script type="module" src="./app/main.js"></script>
...
<script>require(["layer-manager"]);</script> then in my main.ts file I do: import LayerManager = require("layer-manager/LayerManager"); I'm trying to use snowpack in dev mode to bundle and serve my code locally, but I'm getting the error: Uncaught ReferenceError: require is not defined from those lines in index and main. I see the note in the docs that says: Although Dojo has been removed from a majority of the API, it is still needed in this case to load the AMD modules. I'm guessing none of my code is pulling in dojo, so it doesn't have access to require. I tried adding a script tag to my index.html: <script src="//ajax.googleapis.com/ajax/libs/dojo/1.14.1/dojo/dojo.js"></script> but that gives me this error: dojo.js.uncompressed.js:129 Uncaught Error: undefinedModule I also see here https://developers.arcgis.com/javascript/latest/tooling-intro/#compare-amd-and-es-modules that esm local builds might not even be possible when using dojo1. What is the recommended way for loading custom widgets and is it possible to load custom widgets using the ES modules and a bundler like snowpack?
... View more
07-23-2021
12:17 PM
|
0
|
2
|
917
|
POST
|
If you don't want to re-write the code, you should be able to bring dojo into your project separately from the arcgis api: https://dojotoolkit.org/download/ Either add the cdn url in a script tag to your index.html, or download the toolkit and link to it from your local copy.
... View more
07-22-2021
08:41 AM
|
2
|
1
|
1830
|
POST
|
Nice. Works perfectly. Now I just need to dive in and figure out why the one I set up won't run snowpack dev. I was pleasantly surprised snowpack build worked out of the box, too. EDIT: After removing assets from the mount param from module.exports in snowpack.config.js, everything works now.
... View more
07-15-2021
01:03 PM
|
0
|
0
|
8751
|
POST
|
So that knocked out all but two errors. Still getting node_modules/@types/estree/index"' has no exported member named 'ChainExpression'. Did you mean 'ThisExpression'? and /node_modules/@types/estree/index"' has no exported member 'ImportExpression'. removing node_modules and package-lock.json and running npm install again seems to have fixed this. Thanks for your help!
... View more
07-15-2021
12:15 PM
|
1
|
0
|
8762
|
POST
|
I have a basic index.ts file: import ArcGISMap from '@arcgis/core/Map';
import MapView from '@arcgis/core/views/MapView';
import Search from '@arcgis/core/widgets/Search';
const map = new ArcGISMap({
basemap: 'topo-vector'
});
const view = new MapView({
container: 'viewDiv',
map: map,
zoom: 10,
center: [118, 34]
});
const search = new Search({
view
});
view.ui.add(search, 'top-right'); and tsconfig copied from here. When I do npx tsc I get several errors: node_modules/@arcgis/core/interfaces.d.ts:1:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: (Then a huge list) node_modules/@types/arcgis-js-api/index.d.ts:8:1 8 type HashMap<T> = Record<string, T>; Conflicts are in this file. node_modules/@arcgis/core/interfaces.d.ts:31568:5 - error TS2687: All declarations of 'address' must have identical modifiers. node_modules/@types/eslint/index.d.ts:451:42 - error TS2724: '"C:/Users/bromlein/Documents/snowpack-demo/node_modules/@types/estree/index"' has no exported member named 'ChainExpression'. Did you mean 'ThisExpression'? 451 ChainExpression?: ((node: ESTree.ChainExpression & NodeParentExtension) => void) | undefined; node_modules/@types/eslint/index.d.ts:474:43 - error TS2694: Namespace '"C:/Users/bromlein/Documents/snowpack-demo/node_modules/@types/estree/index"' has no exported member 'ImportExpression'. 474 ImportExpression?: ((node: ESTree.ImportExpression & NodeParentExtension) => void) | undefined; package.json: {
"name": "snowpack-demo",
"version": "1.0.0",
"description": "",
"main": "./src/index.js",
"scripts": {
"start": "snowpack dev",
"build": "snowpack build",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@snowpack/plugin-typescript": "^1.2.1",
"@snowpack/plugin-webpack": "^3.0.0",
"@types/arcgis-js-api": "^4.20.1",
"snowpack": "^3.8.2",
"tslib": "^2.3.0",
"typescript": "^4.3.5"
},
"dependencies": {
"@arcgis/core": "^4.20.2"
},
"browser": {
"fs": false,
"path": false
}
} what am I missing?
... View more
07-15-2021
10:33 AM
|
0
|
4
|
8767
|
POST
|
Thanks for the replies, I really appreciate your help. I looked at it again today and it's working now. I'm not really sure which change did the trick and I also cleared my cache since working on it last, but whatever the case, I'm very pleased to have this bug in my app fixed, so thank you very much once again. For reference, this is the add layer code block in its current working form: async add(layerRef: LayerRef): Promise<void> {
layerRef.status = "active"
if (layerRef.type === "TileLayer") {
const layer = new TileLayer({
url: layerRef.url,
id: layerRef.group + "-" + layerRef.name,
});
const fieldInfos = await this._getFieldInfo(layerRef);
layer.when(function(layer: TileLayer){
const fieldContent = new FieldsContent({
fieldInfos: fieldInfos
});
const featsSublayer: Sublayer = layer.findSublayerById(0)
featsSublayer.popupTemplate = new PopupTemplate({
title: layerRef.name,
content: [fieldContent],
outFields: ["*"]
});
featsSublayer.load();
featsSublayer.popupEnabled = true;
});
this._addToMap([layer]);
... View more
06-16-2021
09:23 AM
|
0
|
0
|
2019
|
POST
|
So I tried moving the load() and _addToMap calls around a bunch and none of the combinations resulted in the popups working. Most recently I tried putting everything within the when and addToMap after popupenabled with the same result: async add(layerRef: LayerRef): Promise<void> {
layerRef.status = "active"
if (layerRef.type === "TileLayer") {
const layer = new TileLayer({
url: layerRef.url,
id: layerRef.group + "-" + layerRef.name,
});
const fieldInfos = await this._getFieldInfo(layerRef);
layer.when(function(layer: TileLayer){
const featsSublayer: Sublayer = layer.findSublayerById(0)
const fieldContent = new FieldsContent({
fieldInfos: fieldInfos
})
featsSublayer.popupTemplate = new PopupTemplate({
title: layerRef.name,
content: [fieldContent],
outFields: ["*"]
});
featsSublayer.load();
featsSublayer.popupEnabled = true;
this._addToMap([layer]);
}); I'm having a hard time setting up a pen, but I've got this: https://codepen.io/broms/pen/dyvQBVN that loads a TileLayer. I can't figure out why findSublayerById isn't working. I log the layer to console and I can see the sublayer there, but I'm getting an error setting popupTemplate that sublayer is undefined. EDIT: I've got the pen to where it's displaying popups but I'm having trouble setting the content of the popups. Also not sure how to duplicate this in my widget. I think it's like you said, some async stuff isn't lined up right. Do you have any tips on how to debug this? I'm really in the dark, I can't even get console logging to work within my viewmodel methods.
... View more
06-14-2021
09:44 AM
|
0
|
1
|
2052
|
POST
|
Thank you so much, this has resolved the type errors. However I'm still not getting my popups. const fieldInfos = await this._getFieldInfo(layerRef);
layer.when(function(layer: TileLayer){
const featsSublayer: Sublayer = layer.findSublayerById(0)
featsSublayer.load();
featsSublayer.popupEnabled = true;
const fieldContent = new FieldsContent({
fieldInfos: fieldInfos
})
featsSublayer.popupTemplate = new PopupTemplate({
title: layerRef.name,
content: [fieldContent],
outFields: ["*"]
});
});
this._addToMap([layer]); When I add a layer using this code and log map.layers to console, I can see my layer is there, but in its sublayers array, the sublayer shows: loaded: false
popupEnabled: true
PopupTemplate: null I tried moving the sublayer.load, and popupTemplate declaration to happen after the layer is added to map, but it still doesn't seem to be loading or setting the popupTemplate.
... View more
06-11-2021
05:18 PM
|
0
|
4
|
2092
|
POST
|
Thanks for the reply. I tried this: const fieldInfos = await this._getFieldInfo(layerRef);
layer.when(function(layer: TileLayer){
const featsSublayer: Sublayer = layer.findSublayerById(0)
featsSublayer.load();
featsSublayer.popupEnabled = true;
const fieldContent = new FieldsContent({
fieldInfos: fieldInfos
})
featsSublayer.popupTemplate = {
title: layerRef.name,
content: [fieldContent],
outFields: ["*"]
}
}); and I'm getting a type error on featsSublayer.popupTemplate now: Type '{ title: string; content: FieldsContent[]; outFields: string[]; }' is missing the following properties from type 'PopupTemplate': actions, expressionInfos, fieldInfos, lastEditInfoEnabled, and 16 more.ts(2740) I also tried this: const fieldInfos = await this._getFieldInfo(layerRef);
layer.when(function(layer: TileLayer){
const featsSublayer = layer.findSublayerById(0)
featsSublayer.load();
featsSublayer.popupEnabled = true;
featsSublayer.popupTemplate = {
title: layerRef.name,
content: new FieldsContent({
fieldInfos: fieldInfos,
}),
outFields: ["*"]
}
}); and get this error on content: Type 'FieldsContent' is not assignable to type 'string | Function | Promise<any> | Content[]'. Type 'FieldsContent' is missing the following properties from type 'Content[]': length, pop, push, concat, and 26 more.ts(2322)
... View more
06-11-2021
04:46 PM
|
0
|
6
|
2096
|
POST
|
I have a JS API 4.x application that needs to load arbitrary layers provided by users and display popups for these layers. Several of these layers are tile layers. Part of the app is a custom TypeScript widget to add these layers to the map but in it I'm having trouble setting the popup template. I want to use the feature service sublayer of the tile layer to access feature info and display the popups (like in this post). This code finds the fieldInfos for a layer (query the service for all its fields and returns them in an array of field objects with attributes of type, name and alias): private async _getFieldInfo(layer: LayerRef): Promise<Array<{fieldName: string, label: string}>> {
...
const response = await request(fieldUrl, {query: {f: "json"}, responseType: "json"}).then(response => response.data);
const fields = response.fields;
...
const fieldInfos: {fieldName: string, label: string}[] = [];
response.type === "Feature Layer" ? fields.map((field: {name: string, type: string, alias: string}) =>
...
fieldInfos.push({fieldName: field.name, label: field.alias}) : null) : null;
return fieldInfos;
} Then as part of my add layer function, I have: const fieldInfos = await this._getFieldInfo(layerRef);
layer.when(function(layer: TileLayer){
const featsSublayer = layer.findSublayerById(0)
featsSublayer.load();
featsSublayer.popupEnabled = true;
featsSublayer.popupTemplate = {
title: layerRef.name,
content: [{
type: "fields",
fieldInfos: fieldInfos,
}],
outFields: ["*"]
}
}); I'm getting a type error that prevents me from compiling on the fieldInfos variable in the content object of the sublayer popup template: Type '{ type: "fields"; fieldInfos: { fieldName: string; label: string; }[]; }' is not assignable to type 'Content'. Object literal may only specify known properties, and 'fieldInfos' does not exist in type 'Content'.ts(2322) Can anyone point me in the right direction to get my popup template working?
... View more
06-11-2021
12:08 PM
|
0
|
9
|
2143
|
Title | Kudos | Posted |
---|---|---|
1 | 08-09-2023 09:03 AM | |
1 | 04-11-2023 06:29 AM | |
1 | 07-18-2022 08:46 AM | |
1 | 09-01-2020 01:19 PM | |
2 | 08-27-2021 09:02 AM |
Online Status |
Offline
|
Date Last Visited |
03-08-2024
07:08 PM
|