Property 'tags' on Layer item seems to be empty

136
5
Jump to solution
10-15-2018 05:56 AM
CarstenAndersson
New Contributor III

I am building an mobile app in AppStudio, where I need to read tags from layers.

It is based on the MapViewer template, and I have a web map that contains a layer (stored as an item on ArcGIS Online). When I click on the map it iterates through the layers and adds them to the map view. Currently the map only contains my layer and a base map. I've added a tag on the layer item, and I'm positive, that I got the correct layers. I can see that when I write the item id in the console log. But still the tags written to the console log is empty.

Has anyone else had this issue? And if so, is there a fix to this.

Thanks in advance.

/Carsten

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

I'm not aware of any issues. The following prints out tags for me:

import QtQuick 2.6
import QtQuick.Controls 1.4
import Esri.ArcGISRuntime 100.3

ApplicationWindow {
    id: appWindow
    width: 800
    height: 600   

    // add a mapView component
    MapView {
        anchors.fill: parent
        // set focus to enable keyboard navigation
        focus: true

        // add a map to the mapview
        Map {
            initUrl: "http://www.arcgis.com/home/item.html?id=392451c381ad4109bf04f7bd442bc038"
            onLoadStatusChanged: {
                if (loadStatus === Enums.LoadStatusLoaded) {
                    operationalLayers.forEach(function(lyr) {
                        if (lyr.loadStatus === Enums.LoadStatusLoaded) {
                            console.log(lyr.name, "tags:", lyr.item.tags)
                        } else {
                            lyr.loadStatusChanged.connect(function() {
                                if (lyr.loadStatus === Enums.LoadStatusLoaded) {
                                    console.log(lyr.name, "tags:", lyr.item.tags)
                                }
                            });
                            lyr.load();
                        }
                    });
                }
            }
        }
    }
}

View solution in original post

5 Replies
ErwinSoekianto
Esri Regular Contributor

Carsten,

How do you get the item id and tags from layer item in ArcGIS Online? Is it using REST API call? 

Based on this documentation, Item—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers , the id and the tag, should be returned in the same json response. 

So for your scenario, it only returns the id but the tag is empty? Can you try it calling the REST endpoint using PostMan or in the browser to see the json response, weather it included tag or not. 

Erwin

0 Kudos
CarstenAndersson
New Contributor III

Hi Erwin.

No, the app is written using AppStudio Qt/QML. I have the map object, that contains all the operational layers (see: https://developers.arcgis.com/qt/latest/qml/api-reference/qml-esri-arcgisruntime-map.html). I iterate through the layers. The layers are all created as items (see: https://developers.arcgis.com/qt/latest/qml/api-reference/qml-esri-arcgisruntime-layer.html ), so through that I can get the item property and retrieve tags (see: https://developers.arcgis.com/qt/latest/qml/api-reference/qml-esri-arcgisruntime-arcgisitem.html). The value itemId property is correct, but the tags are empty.

So I am not using REST calls 🙂

/Carsten

0 Kudos
CarstenAndersson
New Contributor III

This is the code I am using to get tags:

layer.onLoadStatusChanged.connect(function () {
   if (layer.loadStatus === Enums.LoadStatusLoaded) {
      console.log("layer loaded!");
      console.log("layer=" + layer);
      console.log("layer.name=" + layer.name);
      console.log("layer.item.itemId=" + layer.item.itemId);
      console.log("layer.item.tags=" + layer.item.tags);
   }
});

0 Kudos
ErwinSoekianto
Esri Regular Contributor

Looping in ArcGIS Runtime SDK for Qt‌, to see if it this a known issue or if there is another way to get tags from layer item.

LucasDanzinger
Esri Frequent Contributor

I'm not aware of any issues. The following prints out tags for me:

import QtQuick 2.6
import QtQuick.Controls 1.4
import Esri.ArcGISRuntime 100.3

ApplicationWindow {
    id: appWindow
    width: 800
    height: 600   

    // add a mapView component
    MapView {
        anchors.fill: parent
        // set focus to enable keyboard navigation
        focus: true

        // add a map to the mapview
        Map {
            initUrl: "http://www.arcgis.com/home/item.html?id=392451c381ad4109bf04f7bd442bc038"
            onLoadStatusChanged: {
                if (loadStatus === Enums.LoadStatusLoaded) {
                    operationalLayers.forEach(function(lyr) {
                        if (lyr.loadStatus === Enums.LoadStatusLoaded) {
                            console.log(lyr.name, "tags:", lyr.item.tags)
                        } else {
                            lyr.loadStatusChanged.connect(function() {
                                if (lyr.loadStatus === Enums.LoadStatusLoaded) {
                                    console.log(lyr.name, "tags:", lyr.item.tags)
                                }
                            });
                            lyr.load();
                        }
                    });
                }
            }
        }
    }
}

View solution in original post