portalitem=new PortalItem

233
2
07-24-2020 03:13 AM
DidarBultanov
New Contributor II

I want to load maps from my portal

<link
rel="stylesheet"
href="https://gis.kgp.kz/arcgis_js_api/library/4.16/esri/themes/light/main.css"
/>

<script src="https://gis.kgp.kz/arcgis_js_api/library/4.16/dojo/dojo.js""></script>

<script>

require([
"https://gis.kgp.kz/arcgis_js_api/library/4.16/esri/portal/PortalItem.js",
"https://gis.kgp.kz/arcgis_js_api/library/4.16/esri/views/MapView.js",
"https://gis.kgp.kz/arcgis_js_api/library/4.16/esri/WebMap.js"

], function (
PortalItem,
MapView,
WebMap
) {

var portalitem= new PortalItem({
id:"0ce4b182600b4ea78afdcda6ec8428e8",
portal:"https://gis.kgp.kz/portal",
type:"Web Map"
});
var webmap = new WebMap({
portalItem:portalitem
});

//console.log(webmap.portalItem+" "+esriConfig.PortalUrl);
var view = new MapView({
map: webmap,
container: "viewDiv"
});
});
</script>

I get an error:

dojo.js:115 [esri.core.Accessor] Accessor#set Assigning an instance of 'esri.portal.PortalItem' which is not a subclass of 'esri.portal.PortalItem'

0 Kudos
2 Replies
Arne_Gelfert
Regular Contributor

Not sure about your specific error... I've seen something similar when the order of function arguments does not match the order of require arguments. But that seems to be correct. Is there a reason why you can't reference the CDN version of JSAPI?

When I try the following, which is similar  to your examples, it works"

<html>
  <head>
    ...
// Reference the JSAPI here 
<script src="https://js.arcgis.com/4.16/"></script>

<script>
// Only reference module names not the full path like you did
require([
"esri/portal/PortalItem",
"esri/WebMap",
"esri/views/MapView",

], function (
PortalItem,
WebMap,
MapView
) {

// Grab anitem from your Portal
var portalitem = new PortalItem({
  id: "< some item Id >",
  portal:"<my own portal URL >"}
);
portalitem.load();

// Create a web map with that item
var webmap = new WebMap({
  portalItem: portalitem
  
});

// Crwate  a view to hold the map
var view = new MapView({
  map: webmap,  // The WebMap instance created above
  ...
});

});
</script>
</head>

<body>
  <div id="viewDiv"</div>
</body>

</html>
  ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Not saying what you tried can't work but the above looks more familiar to me.

DidarBultanov
New Contributor II

Users work without the Internet

for this reason, I placed the library locally on the server

My Web map https://gis.kgp.kz/portal/home/webmap/viewer.html?webmap=0ce4b182600b4ea78afdcda6ec8428e8 

My test html https://gis.kgp.kz/test_kz.html 

0 Kudos