Select to view content in your preferred language

Javascript Template without ArcGIS.com Map Services?

8042
19
11-17-2011 01:46 PM
ChrisPyle
Emerging Contributor
Is it possible to use the ArcGIS.com javascript templates w/out ArcGIS.com hosted maps?

We're trying to edit a feature service that's on our intranet, and so it is not accessible via ArcGIS.com. I've seen how to add a map definition using JSON instead of just a mapID.
I've been able to load a map hosted on Arcgis.com via the JSON definitition, but when I try to point to our internal services, the map fails to initialize. When initializing, the layer objects under each map layer are all undefined.

So, using the Editor_Chrome template, this works to define the ConfigOptions.webmap:

        var webmap = {}; webmap.item = { "title": "Soil Survey Map of USA", "snippet": "Detailed description of data", "extent": [[-139.4916, 10.7191], [-52.392, 59.5199]] };
        webmap.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"    };
  


But this does not:

        var webmap = {}; webmap.item = { 
        "title": "San Diego Special Events", 
        "snippet": "Special Events Locations", 
        "extent": [[6171671, 1760860], [6621931, 2102353]] };
 
        webmap.itemData = { "operationalLayers": [{
        "url": "http://vmgisprod3/ArcGIS/rest/services/SEPS_Edit/FeatureServer",
        "visibility": true,
        "opacity": 1,
        "title": "Special Events Map",
        "itemId": "204d94c9b1374de9a21574c9efa31164"
        }],
        "baseMap": {
        "baseMapLayers": [{
        "opacity": 1,
        "visibility": true,
        "url": "http://citymaps.sannet.gov/ArcGIS/rest/services/SanGIS_Basemap/MapServer"
        }, {
        "isReference": true,
        "opacity": 1,
        "visibility": true,
        "url": "http://citymaps.sannet.gov/ArcGIS/rest/services/SanGIS_Basemap/MapServer"
        }],
        "title": "San Diego Basemap"
        },
        "version": "1.1"
        };
 


Is there a definition of the JSON webmap syntax somewhere that might give me a clue?

Thanks,
-Chris
19 Replies
Asgharkhan
Regular Contributor

i am stuck on "webmap": "204d94c9b1374de9a21574c9efa31164", on defaults.js

how i use ur codes in this situation?

Please Guide me

Regards

0 Kudos
NewUser
Emerging Contributor
I'm trying to figure how I'd go about removing the webmap in the basic viewer template too.

Would I basically comment out the webmap id in the index.html and build a webmap in the layout.js?  Maybe using Create web map using JSON as an example, using my own services?
0 Kudos
NewUser
Emerging Contributor
I created this function based on the Create web map using and JSON sample and  placed it in the basic viewer index.html.
 function add() {
        var webmap = {};
        webmap.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]]
        };

        webmap.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"
        };

       return webmap;
}
In the index.html, I then changed
webmap: "dbd1c6d52f4e447f8c01d14a691a70fe",
to
webmap: add(),
It seems to work fine and when I click on a soil polygon the popup works as expected.  The trouble I'm having is when I switch to an operational layer on my server, it's added to the map and displays in the legend just fine, but the identify popup doesn't work.  Any thoughts on what I can troubleshoot?
0 Kudos
NewUser
Emerging Contributor
I was able to configure the popup by configuring the "popupInfo": in my operationallayer.

One thing I noticed is that my ability to zoom in seems to be limited to about 1" = 1 mile....the same behavior as the Create web map from JSON sample.  Where is this controlled?
0 Kudos
NewUser
Emerging Contributor
It looks like this is determined by maybe a scale range set in the basemap?  I changed the basemap to OpenStreetMap and I can zoom in as far as I want.  I added Bing and can also zoom in as far as I want, but I noticed that the x,y coordinates I have displayed below the map disappear if I use Bing, but not if I use OpenStreetMap.  I've added Bing to the basemapgallery and if I use OpenStreetMap as the Basemap in the webmap and then switch to Bing from the basemapgallery, the x,y coordinates are also fine.  Thoughts as to what the issue might be?
0 Kudos
ryanreise
Deactivated User
It looks like this is determined by maybe a scale range set in the basemap?  I changed the basemap to OpenStreetMap and I can zoom in as far as I want.  I added Bing and can also zoom in as far as I want, but I noticed that the x,y coordinates I have displayed below the map disappear if I use Bing, but not if I use OpenStreetMap.  I've added Bing to the basemapgallery and if I use OpenStreetMap as the Basemap in the webmap and then switch to Bing from the basemapgallery, the x,y coordinates are also fine.  Thoughts as to what the issue might be?


Thanks for documenting your workflows. This thread has been very usefull for me. Did you ever figure out how to disable this zoom restriction on the esri basemap layers?
0 Kudos
Mtclimber03
Regular Contributor
new2jsapi could you tell me where exactly in the index.html you inserted the code snippet from https://developers.arcgis.com/javascript/jssamples/ags_createwebmapitem.html ? I'm having trouble getting this to work. I'm familiar with digging through this code but not an expert by any means. I've already replaced the webmap ID with "webmap: add(),"
0 Kudos
EzequiasRodrigues_da_Rocha1
Deactivated User

How is your progress?

I would also like to know how to point to a ArcGIS Server ID instead of an AGOL.

Regards

Ezequias

DanielSmith
Frequent Contributor

... how to point to a ArcGIS Server ...

Add Function to use our ArcGIS server services · Issue #16 · Esri/Viewer · GitHub

this should help

0 Kudos
AdamJoseph1
Deactivated User

an alternative way to provide your webmap is from cartoview which is free. Cartoview 

0 Kudos