Select to view content in your preferred language

Basemap from multiple services

3560
6
Jump to solution
10-30-2013 04:15 AM
GregYetman
Deactivated User
Hi,

Is there a way to setup a basemap that combines two services? Specifically, I'd like to combine a set of tiles generated for a specific area with the existing Esri topographic basemap and have that available as a basemap option in the organizational site.

I uploaded the tiles (using the standard AGOL tiling scheme):

http://apps4halifax.maps.arcgis.com/home/item.html?id=c844ca39d4ef4dc5bef1e53437033111

Authored a "community basemap" web map that combines the tiles with the default AGOL basemap:

http://apps4halifax.maps.arcgis.com/home/item.html?id=dd99b6f379094ad7bda80739369f624c

and added the web map to the Basemaps group, and it shows up in the list of basemaps for the organization. The problem is that when a user creates a new new map with the "community basemap", only the default topographic basemap is shown, not the custom tiles that are in the web map.

Any suggestions for a work around?

If not, I'll add this to the ideas site. I can see uses for it outside of the topographic basemap, such as augmenting the Esri imagery basemap with more detailed or up-to-date imagery to create a custom basemap.

TIA,

Greg
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MikeMinami
Esri Notable Contributor
When you author custom basemaps, only the basemap layer is used; thus you don't see your other layers.

The API currently supports multi-layered basemaps. The user interface in arcgis.com doesn't expose this currently, although we would like to expose this.

If you're good at coding, here are some resources you may find helpful.

http://resources.arcgis.com/en/help/arcgis-rest-api/#/baseMap/02r30000003w000000/
http://resources.arcgis.com/en/help/arcgis-rest-api/#/Two_basemap_layers/02r300000046000000/
http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r30000009s000000

Thanks,

Mike

View solution in original post

0 Kudos
6 Replies
MikeMinami
Esri Notable Contributor
When you author custom basemaps, only the basemap layer is used; thus you don't see your other layers.

The API currently supports multi-layered basemaps. The user interface in arcgis.com doesn't expose this currently, although we would like to expose this.

If you're good at coding, here are some resources you may find helpful.

http://resources.arcgis.com/en/help/arcgis-rest-api/#/baseMap/02r30000003w000000/
http://resources.arcgis.com/en/help/arcgis-rest-api/#/Two_basemap_layers/02r300000046000000/
http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r30000009s000000

Thanks,

Mike
0 Kudos
StephanieWendel
Esri Contributor
Here is a script sample I've been working on to do this:

import urllib, urllib2, httplib
import json
import socket

# User Variables

username = "" 
password = "" 


# Monkey Patch httplib read
def patch_http_response_read(func):
    def inner(*args):
        try:
            return func(*args)
        except httplib.IncompleteRead, e:
            return e.partial

    return inner

httplib.HTTPResponse.read = patch_http_response_read(httplib.HTTPResponse.read)

# Get token
hostname = "Http://" + socket.getfqdn()

token_URL = 'https://www.arcgis.com/sharing/generateToken'
token_params = {'username':username,'password': password,'referer': hostname,'f':'json'}
token_request = urllib2.Request(token_URL, urllib.urlencode(token_params))
token_response = urllib2.urlopen(token_request)
token_string = token_response.read()
token_obj = json.loads(token_string)
token = token_obj['token']



# Build the json string
text = {"operationalLayers": [],
        "baseMap": {"title": "Basemap",
                    "baseMapLayers": [{"visibility": "true",
                                        "opacity": 1,
                                        "isReference": "true",
                                        "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
                                        "minScale":1155581,
                                        "maxScale":144448},
                                        {"visibility": "true",
                                        "opacity": 1,
                                        "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
                                        "minScale":144448,
                                        "maxScale":200},
                                        {"visiblity": "true",
                                        "opacity": 1,
                                        "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
                                        "minScale": 500000000,
                                        "maxScale": 1155581}]},
        "version": "1.7"}

query = {"token" : token,
        "f" : "json",
        "text" : text,
        "title" : "Test Basemap",
        "type" : "Web Map",
        "tags" : "basemap, test"}


serviceURL = 'http://www.arcgis.com/sharing/rest/content/users/{}/addItem'.format(username)
createBasemap = urllib2.Request(serviceURL, urllib.urlencode(query))
createBasemap.add_header('Referer', hostname)
createBasemap_response = urllib2.urlopen(createBasemap)
print createBasemap_response.read()


The result will be a webmap that has a basemap that starts with the imagery basemap. As you zoom in it switches to the World Shaded Relief and then the light gray basemap. You can use your own services in this sample to create your own basemap. You can set your own scale levels as well. This is just an example of something I picked. I hope this helps get you started!
0 Kudos
GregYetman
Deactivated User
Thanks, useful info and great starter with the script! I'll post what I get setup once I get back to this next week.

cheers,
0 Kudos
GregYetman
Deactivated User
Hi,

I substituted my account information and the URLs for the basemap and tiled map services that I want to combine. The resulting web map behaves exactly as I would like. However, when I add the web map to the basemaps group and create a new map, the scale dependencies are not respected. Instead, both layers are drawn. Oddly, only one layer is shown in the 'Content' for the web map, but both layers draw. you can see the issue (duplicate streets, buildings, etc.) in the screen shot. The working web map is at the link below.

I guess that creating a basemap from a tiled map service and existing basemap is not possible, unless I am missing something that needs to be changed in the code.

Greg

Screenshot showing the issue when the web map is used as a basemap:
[ATTACH=CONFIG]29074[/ATTACH]

Working web map from code (zoom in to see the switch in layers):
http://apps4halifax.maps.arcgis.com/home/webmap/viewer.html?webmap=696d767bebf348c4acbc78711e8c0fce
0 Kudos
by Anonymous User
Not applicable
Hi Greg,

We have a bug that we're addressing in the December release that will fix this. If the custom multi-layer basemap is used as the default it won't load, but if you switch to a different one and back it should load.

There was also some ordering issues we need to update the script to address. Your basemap layers should show as:

  "baseMapLayers": [
    {
      "id": "World_Imagery_8854",
      "opacity": 1,
      "visibility": true,
      "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
    },
    {
      "id": "MyDynamicLayer_7237",
      "opacity": 1,
      "visibility": true,
      "url": "http://yourserver/arcgis/rest/services/MyDynamicLayer/MapServer",
      "minScale": 4000,
      "maxScale": 1
    },
    {
      "id": "BaseScales_9486",
      "isReference": true,
      "opacity": 1,
      "visibility": false,
      "url": "http://yourserver/arcgis/rest/services/BaseScales/MapServer"
    }
  ],



Cheers,
Andrew
0 Kudos
AndrewBowne
Frequent Contributor

Is it possible to use a multilayer basemap of tiled map services, but specify the LOD's?  I have two tiled map services that have most of the same LOD's however one goes into more detail.  I want to have the one with more detail on top and use that as the LOD reference.

Thanks!

0 Kudos