1

I do not have ArcGIS for Server on my machine to publish services so I have published my map contents into ArcGIS Online as a map package.

Can I add that map package on a map by using its portal itemid?

I want to display my map content on a map for querying.

2

A map package cannot be uploaded directly to Online and be published as a layer. If you open the map package in Pro or ArcMap you can publish the contents to ArcGIS Online as a feature layers and tile layers and then you can use those layers in map viewer, scene viewer or custom apps using WAB or JSAPI.

-1

Yes you can!

But where you are trying to add? Its a web page, desktop or Android?

If you are working on web you can use ArcGIS API for JS and you can add a portal layer using following code.

// Creates a layer from a Portal layer item id
Layer.fromPortalItem({
  portalItem: {
    id: "af1ad38816814b7eba3fe74a3b84412d"
  }
}).then(function(lyr){
  // Adds layer to the map
  map.add(lyr);
}); 

You can find the details here and here also

For Android

If you are developing an Android application you can use ArcGIS Runtime SDK for android and you can use this class

  • Thanks for your suggession, I have tried with portal item id:cc265a1e37204d4ca4eadfaeed5300c8 using in 'create a layer from portal item' code still layer is not visible on map. Url for my mappackage in arcgis online is "arcgis.com/home/item.html?id=cc265a1e37204d4ca4eadfaeed5300c8". can u check where the problem is. – msurya Aug 10 '16 at 10:23
  • 1
    Thats a map package, not a map service or feature service. You cannot create a webapp (JavaScript API for example) that consumes a package. The package has to be 'published' as a service and the service can be consumed. – KHibma Aug 10 '16 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.