Skip to content

Instantly share code, notes, and snippets.

@jgravois
Last active October 12, 2015 01:54
Show Gist options
  • Save jgravois/10035880e7252707890e to your computer and use it in GitHub Desktop.
Save jgravois/10035880e7252707890e to your computer and use it in GitHub Desktop.
add webmap from JSON instead of ArcGIS Online in Viewer.
<script type="text/javascript" src="./config/webmap.js"></script>
<!--existing tag-->
<script type="text/javascript" src="//js.arcgis.com/3.10/"></script>
//...
this._createWebMap(customWebmap);
var customWebmap = {};
customWebmap.item = {
"title": "Soil Survey Map of USA",
"snippet": "This map shows the Soil Survey Geographic (SSURGO) by the United States Department of Agriculture's Natural Resources Conservation Service.",
"extent": [
[-139.4916, 10.7191],
[-52.392, 59.5199]
]
};
customWebmap.itemData = {
"operationalLayers": [{
"url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/Soil_Survey_Map/MapServer",
"visibility": true,
"opacity": 0.75,
"title": "Soil Survey Map",
"itemId": "204d94c9b1374de9a21574c9efa31164"
}],
"baseMap": {
"baseMapLayers": [{
"opacity": 1,
"visibility": true,
"url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer"
}, {
"isReference": true,
"opacity": 1,
"visibility": true,
"url": "http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer"
}],
"title": "World_Terrain_Base"
},
"version": "1.1"
};
@jgravois
Copy link
Author

an alternative approach (and probably superior one) would be to define the webmap JSON directly within the config object here

@asgharkhall
Copy link

How i change "webmap": "204d94c9b1374de9a21574c9efa31164" in default.js ?

@jgravois
Copy link
Author

based on your extremely limited explanation, its hard to understand the exact problem you're having.

if you're failing to override the instantiation of a map using an id from 'default.js', you need to make sure you are commenting out this line and replacing it with the call here to substitute custom logic and custom JSON content.

that being said, in most cases that developers are incorrect about their inability to reference a webmap via ID in their own project, so think long and hard about whether any of this is even necessary.

@asgharkhall
Copy link

Sir , actually the problem is this template , this is responsive Js Template of basic viewer , now my problem is what , in defaults.js there are webmap id , i want own map services with json ,
thanks for help .
http://www.arcgis.com/home/item.html?id=b17113eb9535427db477777f86f25d63
this is the viewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment