Select to view content in your preferred language

PortalItem FeatureLayer is not shown

226
3
4 weeks ago
SalvadorApltp
Emerging Contributor

I've got the same piece of code in two apps.

In the test app, the portalItem is shown.

In the main app I'm working on, it is not. Other operational layers like WMS are in fact shown.

Screenshot_2024-09-24-15-21-08-253_com.aplitop.tcpgps.jpg

Screenshot_2024-09-24-15-21-20-112_com.aplitop.displayportalitemlayerjava.jpg

ArcGISMap map = new ArcGISMap(SpatialReferences.getWebMercator());
map.setBasemap(Basemap.createTopographicVector());
MapView mapView = view.findViewById(R.id.testmap);
mapView.setMap(map);

Portal portal = new Portal("https://www.arcgis.com");
PortalItem portalItem = new PortalItem(portal, "257f279bf6a5461e88db07f54aa85d71");
portalItem.loadAsync();
portalItem.addDoneLoadingListener(new Runnable() {
@Override
public void run() {
if (portalItem.getLoadStatus().equals(LoadStatus.FAILED_TO_LOAD)) {
portalItem.retryLoadAsync();
} else if (portalItem.getLoadStatus().equals(LoadStatus.LOADED)) {
FeatureLayer featureLayer = new FeatureLayer(portalItem);
Viewpoint viewpoint = new Viewpoint(36.7324863, -4.46812351, 500);
mapView.setViewpointAsync(viewpoint);
mapView.getMap().getOperationalLayers().add(featureLayer);
}
}
});

I'm a bit confused, as the code is the same, but the results are not. Any sort of guidance to find the root of the problem would be welcome. It is not the license, as I've tried with the same developer test license, with the same result, as well.

Thank you.

UPDATE EDIT:

It would seem that the license did make more of an effect than I thought. It is still weird. I have a separate map that I made, isolated, and with the development API KEY, it does work, as opposed with my LITE license. I do not understand, as I was under the impression that the LITE license would work with most of PortalItem's and FeatureLayer's methods.

Thing is, after I've loaded and drawn the PortalItem FeatureLayer, after I go to the app's "main map", it is drawn, but with really thick lines.

Screenshot_2024-09-25-12-22-41-572_com.aplitop.tcpgps.jpg

Screenshot_2024-09-25-12-23-21-962_com.aplitop.tcpgps.jpg

I do not know why I need to draw it into a different map, before getting drawn again. Further ideas and clarifications would be welcome.

0 Kudos
3 Replies
Nicholas-Furness
Esri Regular Contributor

Hi @SalvadorApltp .

The License string and the API Key are different things and independent of each other:

  • The License string removes the developer watermark and enables specific capabilities of the SDK (depending on the license level). You always need a License string to deploy your app to production. If you don't provide a License string, you can use all the capabilities, but only for development and testing.
  • The API Key grants an access token you can use to access hosted content. You only need an API Key if you are accessing private content (as you are).

See these topics for more information (note, I am linking to the ArcGIS Maps SDK for Kotlin documentation since the ArcGIS Runtime SDK for Android is in extended support):

In this reply I focused on API Key because that seems to be what you're using, but note that API Key is just one way to access secure (private) content. You can learn more at the Security and authentication link above.

0 Kudos
SalvadorApltp
Emerging Contributor

Thank you kindly for the clarification, @Nicholas-Furness I was indeed confused about the terminology and you have cleared things up.

I expected the Lite license we're using to be enough to load the PortalItem and have it be shown, but it is not the case.

Considering that the PortalItem, despite loading, is not drawn on the map, I presume that the PortalItem is in fact part of the Location Services, and therefore you need a proper API Key or an Oauth 2.0?

For some reason, I thought the Esri Living Atlas would be "public content", but you mention that it is private content?

Thank you kindly for your time in clarifying these matters, it is of immense help.

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Hi.

Yeah, not all Living Atlas content is completely free. You can see from the details page of the item in question, that it's "Subscriber" content.

2024-10-02_11-59-39.png

You can learn more about what that means here, but the short of it is that you'll need to authenticate to use it. It won't cost you any credits to access, but there are some items of content that for various reasons we cannot just open up publicly. You should be able to use a user-based or app-based OAuth token.

0 Kudos