Map Object Properties: How do I tell if it's a basemap programmatically?

183
5
Jump to solution
2 weeks ago
AlfredBaldenweck
MVP Regular Contributor

AlfredBaldenweck_0-1715270153109.png

I have several map objects in my APRX. One of them is specifically a basemap object, created using "Right-click-->New--> New Basemap"

AlfredBaldenweck_1-1715270196779.png

What I'm running into now is: How do I tell that it's a Basemap using arcpy? 

Looking at the actual documentation for both the APRX and the Map objects, it doesn't seem possible, which is bizarre.

 

0 Kudos
1 Solution

Accepted Solutions
Brian_Wilson
Occasional Contributor III

I did some testing and found the isBasemapLayer of a layer would only tell me if the layer was an ESRI basemap, not my own.

When I created a map, and examined it in the debugger, I found it has a mapType of BASEMAP.

This snippet lists the name and type of each map in my project.

I found this by looking in the map objects in the debugger. (Visual Studio Code in my case)

import arcpy
p = "K:/Taxmaps/taxmaps2.aprx"
project = arcpy.mp.ArcGISProject(p)
print()
map = project.listMaps(wildcard="*")
for m in map:
    print("map:", m.name, " type:", m.mapType)
pass

Output from code:

map: Clatsop County B&W tiles type: BASEMAP
map: County Overview Map type: MAP
map: Map type: MAP
map: Main Map type: MAP
map: Section Overview Map type: MAP
map: Township Overview Map type: MAP

View solution in original post

5 Replies
BlakeTerhune
MVP Regular Contributor

Apologies if I'm missing something obvious, but would it be the isBasemapLayer property on the layer object?

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

I think that's referring to like, this?

AlfredBaldenweck_0-1715271136936.png

I want the map object that I created.

Brian_Wilson
Occasional Contributor III

I did some testing and found the isBasemapLayer of a layer would only tell me if the layer was an ESRI basemap, not my own.

When I created a map, and examined it in the debugger, I found it has a mapType of BASEMAP.

This snippet lists the name and type of each map in my project.

I found this by looking in the map objects in the debugger. (Visual Studio Code in my case)

import arcpy
p = "K:/Taxmaps/taxmaps2.aprx"
project = arcpy.mp.ArcGISProject(p)
print()
map = project.listMaps(wildcard="*")
for m in map:
    print("map:", m.name, " type:", m.mapType)
pass

Output from code:

map: Clatsop County B&W tiles type: BASEMAP
map: County Overview Map type: MAP
map: Map type: MAP
map: Main Map type: MAP
map: Section Overview Map type: MAP
map: Township Overview Map type: MAP

AlfredBaldenweck
MVP Regular Contributor

No idea how I missed that.

Thanks!

0 Kudos
BlakeTerhune
MVP Regular Contributor

@AlfredBaldenweck wrote:

No idea how I missed that.


I looked right at it and moved on. The documentation for mapType says, "Returns a string value that reports the Map object's type information. If the Map is 2D, MAP is returned. If the Map is 3D, SCENE is returned." It implies those are the only two options, which is clearly not the case. I am submitting feedback on that page to be more descriptive of the mapType property.