Hi,
I had followed this example, JS Bin - Collaborative JavaScript Debugging and it did worked, but it is hardcoded.
i tried it in my app through this hardcoded it works . But when i tried this property of webmap using my app token and made my webapp private. this link return the below and when i tried to use in webmap it gives the error:
return JSON:
{"operationalLayers":[],"baseMap":{"baseMapLayers":[{"id":"World_Imagery_2017","layerType":"ArcGISTiledMapServiceLayer","url":"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer","visibility":true,"opacity":1,"title":"World Imagery"},{"id":"VectorTile_7259","type":"VectorTileLayer","layerType":"VectorTileLayer","title":"Hybrid Reference Layer","styleUrl":"https://cdn.arcgis.com/sharing/rest/content/items/30d6b8271e1849cd9c3042060001f425/resources/styles/root.json","isReference":true,"visibility":true,"opacity":1}],"title":"Imagery Hybrid"},"spatialReference":{"wkid":102100,"latestWkid":3857},"authoringApp":"WebMapViewer","authoringAppVersion":"8.1","version":"2.16"}
CODE::
esriRequest("https://www.arcgis.com/sharing/rest/content/items/mywebmapid/data?f=json&token=mytokengenerated").then(function(json) {
console.log(json);
const webmap = WebMap.fromJSON(json);
const view = new MapView({
map: webmap,
container: "viewDiv"
});
Error:
dojo.js:253 [esri.WebMap] #load() Failed to load web map d {name: "webmap:invalid-version", message: "Expected major version to be a number, but got ''", details: {…}}
I also tried it through other getJSON method and ajax method, it return the same error.
But when i tried to use hardcode return JSON directly to access my webmap, it works.. like below code
var webmapJSON={"operationalLayers":[],"baseMap":{"baseMapLayers":[{"id":"World_Hillshade_895","layerType":"ArcGISTiledMapServiceLayer","url":"https://services.arcgisonline.com/arcgis/rest/services/Elevation/World_Hillshade/MapServer","visibility":true,"opacity":1,"title":"World Hillshade"},{"id":"VectorTile_6451","type":"VectorTileLayer","layerType":"VectorTileLayer","title":"World Topographic Map","styleUrl":"https://cdn.arcgis.com/sharing/rest/content/items/7dc6cea0b1764a1f9af2e679f642f0f5/resources/styles/root.json","visibility":true,"opacity":1},{"id":"geotiffs_6320","layerType":"ArcGISMapServiceLayer","url":"https://services.arcgisonline.co.nz/arcgis/rest/services/LINZ/geotiffs/MapServer","visibility":true,"opacity":1,"title":"NZ - LINZ Topographic","itemId":"126df938335049028779fbab6d298daf","showLegend":true}],"title":"Topographic"},"spatialReference":{"wkid":102100,"latestWkid":3857},"authoringApp":"WebMapViewer","authoringAppVersion":"8.1","version":"2.16"};
var webmap = WebMap.fromJSON(webmapJSON);
I don't understand where is the problem, i think they are not accessing my webmap but when i used this return hardcode, my app access these globallly used maps..??
also tried through this code..returns same error.
jQuery.ajax({
type : "GET",
async: false,
url : "https://www.arcgis.com/sharing/content/items/mywebmapid/data?f=json&token=mytokengenerated",
success: function(webmapJSON) {
webmap = WebMap.fromJSON(webmapJSON);
console.log(webmap);
//webJson=response;
}//End Success
});//End Ajax
Any help will be appreciable..
Thanks in advance...