Adding a WebMap from Portal to Javascript 4.x application

4335
11
Jump to solution
06-18-2017 09:46 PM
rbae
by
New Contributor III

I'm not able to add a WebMap from Portal to my 4.x application - it looks like it needs something other than portalUrl.  My code works fine for a webmap in arcgis.com.  Does anyone know what I might be missing?  The webmap is shared with everyone and I don't need to log into Portal to see it.

0 Kudos
1 Solution

Accepted Solutions
JohnGrayson
Esri Regular Contributor

Ryan, check the order of the classes in your require... make sure they're declared and used in the same order.

View solution in original post

11 Replies
JayantaPoddar
MVP Esteemed Contributor

To reference an item from an on-premise portal, set the URL of the portal in esriConfig.portalUrl.

 Load a basic WebMap | ArcGIS API for JavaScript 4.3 



Think Location
0 Kudos
rbae
by
New Contributor III

Jayanta,

As I mentioned in my original post, portalUrl does not seem to help.

Thanks,

-Ryan

0 Kudos
rbae
by
New Contributor III
require([
"esri/views/MapView",
"esri/WebMap",
"esri/config",
"dojo/domReady!"
], function (WebMap, MapView, esriConfig) {
portalUrl = "https://www.-------.com/---gis" //THIS DOES NOT SEEM TO DO ANYTHING
var webmap = new WebMap({
portalItem: { // autocasts as new PortalItem()
id: "49d4ffe63e7a4f60ab9ba93ae6d65ce5"
}
});
var view = new MapView({
map: webmap, // References the map object created in step 3
container: "viewDiv" // Reference to the DOM node that will contain the view
});
});
0 Kudos
JeffJacobson
Occasional Contributor III

You're not assigning the URL to the esriConfig.portalUrl. You're currently creating an unrelated variable called portalUrl and assigning a value to it, while esriConfig.portalUrl remains unchanged.

0 Kudos
rbae
by
New Contributor III

Sorry - bad example - that was some debug code.  This is what I currently have, and it is not working.

require([
"esri/views/MapView",
"esri/WebMap",
"esri/config",
"dojo/domReady!"
], function (WebMap, MapView, esriConfig) {
esriConfig.portalUrl = "https://mydomain.com/myportal"
var webmap = new WebMap({
portalItem: { // autocasts as new PortalItem()
id: "49d4ffe63e7a4f60ab9ba93ae6d65ce5"
}
});
var view = new MapView({
map: webmap, // References the map object created in step 3
container: "viewDiv" // Reference to the DOM node that will contain the view
});
});
0 Kudos
KellyHutchins
Esri Frequent Contributor

Try running your app again and watch the network traffic using the browser's debugging tools. You should see a request for your web map id and you can check to make sure the request is for the correct resource. 

0 Kudos
rbae
by
New Contributor III

Kelly,

Sorry for taking so long to get back to you.  I tried what you suggested and found that:

1. Mac OS, Visual Studio Code, Chrome (59.0.3071.115) -> Does not work

2. Windows 10, Visual Studio Code, Chrome (same version as Mac) -> Works!

To eliminate all potential typos, I copied and pasted the code between the two environments.  Is the Mac supported?

Of course, the Windows 10 is running as a VM (VMWare Fusion 8 Pro) on the Mac, so there shouldn't be a network/firewall issue.

Thank you for your help.

-Ryan

0 Kudos
KellyHutchins
Esri Frequent Contributor

Yes mac is supported. I work on a mac on a daily basis and haven't run into any issues with Mac + Chrome and not being able to run an app. When the app doesn't work do you see any errors in the developer tools console? Do you see the request for the web map id? Is it successful? 

JohnGrayson
Esri Regular Contributor

Ryan, check the order of the classes in your require... make sure they're declared and used in the same order.