Select to view content in your preferred language

facing difficulties in displaying shape files larger than 2MB in size

771
7
03-14-2024 09:11 PM
vickylsdev
Emerging Contributor

As my project demands handling shape files ranging from 100-200MB, but their have limitation that you can not upload upto 2MB shape file, this limitation poses a significant obstacle.can anyone  please provide guidance on how to extend the size limit for shape files in the ArcGIS JavaScript API?

7 Replies
Sage_Wall
Esri Contributor

Hi @vickylsdev ,

How are you adding the shapefile to the map? Shapefiles are not directly supported in the JavaScript SDK. Are you creating a client side feature layer? Could you please provide more information?

Without knowing all the details I would suggest publishing the shapefile as a hosted feature service on ArcGIS Online or ArcGIS Enterprise. https://doc.arcgis.com/en/arcgis-online/manage-data/publish-features.htm

vickylsdev
Emerging Contributor

Thanks, I Hosted my shapefile as a hosted layer.  now i am getting another error. Which is 403, unauthorized. I am just adding a layer. although i am owner of that particular layer and i am using owner API key as well. But i am not able to find out what is happening. 

Thanks again for your help.

vickylsdev
Emerging Contributor

Here are error and code:
 image_2024_03_15T12_59_26_085Z.png

<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1, maximum-scale=1, user-scalable=no"
    />
    <title>ArcGIS Maps SDK for JavaScript Tutorials: Add a feature layer</title>
    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    </style>
    <link
      rel="stylesheet"
      href="https://js.arcgis.com/4.29/esri/themes/light/main.css"
    />
    <script src="https://js.arcgis.com/4.29/"></script>

    <script>
      require([
        "esri/config",
        "esri/Map",
        "esri/views/MapView",
        "esri/layers/FeatureLayer",
      ], function (esriConfig, Map, MapView, FeatureLayer) {
        esriConfig.apiKey =
          "API_KEY";

        const map = new Map({
          basemap: "arcgis/topographic",
        });

        const view = new MapView({
          container: "viewDiv",
          map: map,
          center: [35.0, 32.5],
          zoom: 7,
        });

        // Add the shapefile data as a feature layer
        var featureLayer = new FeatureLayer({
          url: "https://services3.arcgis.com/c58gtbRaAKUKM2Hf/arcgis/rest/services/roads/FeatureServer",
        });

        map.add(featureLayer, 0);
      });
    </script>
  </head>
  <body>
    <div id="viewDiv"></div>
  </body>
</html>

 

Sage_Wall
Esri Contributor

Is the API key from a stand alone developers account or from an ArcGIS Online account.  Secured services can only be accessed with an API key from the stand alone pay as you go developers account.  If the api key is from a developers account there is a ui in the configuration of the API key to allow access to specific portal items and services.  With an ArcGIS Online or Enterprise account you need to set up the authentication in another way.  The different authentication types are described here: https://developers.arcgis.com/javascript/latest/secure-resources/

vickylsdev
Emerging Contributor

Hello Sage, 

thank you for your help. we are able to create hosted layer but as we say we are quite confused how do we whitelist an Api key for specific users?
We are not seeing any option here. Also we are using free developer's account do we need to purchase anything for accessing hosted files using API,
also please let me know, if there is any other alternative way to access hosted maps.

 

vickylsdev_0-1710562343776.png

0 Kudos
Sage_Wall
Esri Contributor

Hi @vickylsdev ,

API keys are not tied to specific users but instead authenticate the application itself.  The essentially authorize anyone who uses them with the same privileges, there is no way to distinguish between individual users.  They are essentially just a long lived token without an expiration.

The free developer's account is for testing and prototyping only as you would likely run out of the provided "free" credits in production application pretty quickly, but it's easy to convert into a paid developers account if you do go over those amounts.

To authorize individual access to secured resources you would need to set up an ArcGIS Online organization and add the users you want to be able to access the application as named users in that organization.  After you create an item in ArcGIS Online there is a share button on each resource that gives you fine grained control over individual user access, groups of users, or making the data completely public for everyone by clicking on the share button.

Then you could use OAuth2 and named user authentication.  Individuals then would input their own unique user names and passwords to access the things they have been granted access to.

You could also set up some sort of third party authentication service (AWS Congnito, Microsoft Identity, Google Firebase, ...) as a perimeter authentication into your application and then use multiple API keys to access Esri data and services after the user has authenticated and then use the appropriate key based on the user who logged in.

Some more info can be found in the docs about the different types of authentication for accessing secure resources at https://developers.arcgis.com/javascript/latest/secure-resources/

  • OAuth 2.0 — secures delegated access to server resources.
  • API Keys — a unique identifier used to authenticate a user, developer, or calling program to ArcGIS.
  • ArcGIS Tokens — Esri's proprietary token-based authentication mechanism.
  • Network credentials — HTTPS secured service / Integrated Windows Authentication (IWA).

The alternatives to the developers account we provide for hosting online maps are ArcGIS Online and ArcGIS Enterprise.  Online is very similar to the developers account but allows for more than one user and the billing is credit based.  Enterprise is the self hosted (you run it on your own infrastructure) version of ArcGIS Online.

Sage_Wall
Esri Contributor

Another good doc for info on the different types of authentication and security in general:

https://developers.arcgis.com/documentation/mapping-apis-and-services/security/