<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Add Google Maps as a basemap via Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1624821#M74397</link>
    <description>&lt;P&gt;This works for me, but it's not google maps.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy
import os

# Get project and map
prj = arcpy.mp.ArcGISProject('CURRENT')
m = prj.listMaps()[0]  # Gets the first map

# Path to connection file 
conn_path = os.path.join(os.environ['USERPROFILE'], 'Documents', 'ArcGIS', 'Connections', 'GoogleMaps.wmts')

try:
    # Add the connection
    lyr = m.addDataFromPath(conn_path)
    lyr.name = "Google Satellite"
    
    # Refresh view
    aprx = arcpy.mp.ArcGISProject('CURRENT')
    #aprx.save()
    print("Successfully added Esri World Imagery")
    
except Exception as e:
    print(f"Error: {str(e)}")
    # Alternative legal basemap if Google fails
    world_imagery = m.addDataFromPath(r"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer")
    world_imagery.name = "Esri World Imagery"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jun 2025 20:36:26 GMT</pubDate>
    <dc:creator>TonyAlmeida</dc:creator>
    <dc:date>2025-06-18T20:36:26Z</dc:date>
    <item>
      <title>Add Google Maps as a basemap via Python</title>
      <link>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1624530#M74394</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I'm creating customs webmaps&amp;nbsp; with points and markers using Python.&lt;/P&gt;&lt;P&gt;I'd like to have Google Maps' satellite imagery (&lt;A href="https://mt1.google.com/vt/lyrs=y&amp;amp;x={col}&amp;amp;y={row}&amp;amp;z={level}" target="_blank"&gt;https://mt1.google.com/vt/lyrs=y&amp;amp;x={col}&amp;amp;y={row}&amp;amp;z={level}&lt;/A&gt;) as a basemap. In the online MapViewer it's easy to add a tile layer from an url but I don't see how to do it through Python.&lt;/P&gt;&lt;P&gt;The guide to use the widget (&lt;A href="https://developers.arcgis.com/python/latest/guide/using-the-map-widget/" target="_blank"&gt;https://developers.arcgis.com/python/latest/guide/using-the-map-widget/&lt;/A&gt;) doesn't mention how to add a layer from an url as basemap, and I didn't find any solution in the documentation or in this questions board.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I've also tried manually creating a layer in the My Content folder of my Arcgis Location Platform but the add tile and add layer features are different from that in the online MapViewer.&lt;/P&gt;&lt;P&gt;Any help appreciated.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 00:00:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1624530#M74394</guid>
      <dc:creator>AurelienRobert</dc:creator>
      <dc:date>2025-06-18T00:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Add Google Maps as a basemap via Python</title>
      <link>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1624796#M74396</link>
      <description>&lt;P&gt;You can use the `addDataFromPath` method of a `Map`:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

prj = arcpy.mp.ArcGISProject('CURRENT')
m = prj.listMaps('MapName')[0]

lay: arcpy.mp.Layer = m.addDataFromPath(r'https://mt1.google.com/vt/lyrs=y&amp;amp;x={col}&amp;amp;y={row}&amp;amp;z={level}', 'AUTOMATIC')
lay.name = 'Google Hybrid'
prj.save()&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 18 Jun 2025 19:42:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1624796#M74396</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-06-18T19:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: Add Google Maps as a basemap via Python</title>
      <link>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1624821#M74397</link>
      <description>&lt;P&gt;This works for me, but it's not google maps.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy
import os

# Get project and map
prj = arcpy.mp.ArcGISProject('CURRENT')
m = prj.listMaps()[0]  # Gets the first map

# Path to connection file 
conn_path = os.path.join(os.environ['USERPROFILE'], 'Documents', 'ArcGIS', 'Connections', 'GoogleMaps.wmts')

try:
    # Add the connection
    lyr = m.addDataFromPath(conn_path)
    lyr.name = "Google Satellite"
    
    # Refresh view
    aprx = arcpy.mp.ArcGISProject('CURRENT')
    #aprx.save()
    print("Successfully added Esri World Imagery")
    
except Exception as e:
    print(f"Error: {str(e)}")
    # Alternative legal basemap if Google fails
    world_imagery = m.addDataFromPath(r"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer")
    world_imagery.name = "Esri World Imagery"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 20:36:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1624821#M74397</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-06-18T20:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: Add Google Maps as a basemap via Python</title>
      <link>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1624886#M74398</link>
      <description>&lt;P&gt;Thank you Hayden, unfortunately Cursor tells me arcpy can only be imported when using Arcgis Pro, which I do not have as I use a simple Arcgis online account.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 23:42:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1624886#M74398</guid>
      <dc:creator>AurelienRobert</dc:creator>
      <dc:date>2025-06-18T23:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Add Google Maps as a basemap via Python</title>
      <link>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1624894#M74399</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank you Tony, unfortunately Cursor tells me arcpy can only be imported when using Arcgis Pro, which I do not have as I use a simple Arcgis online account.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 23:43:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1624894#M74399</guid>
      <dc:creator>AurelienRobert</dc:creator>
      <dc:date>2025-06-18T23:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Add Google Maps as a basemap via Python</title>
      <link>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1624921#M74400</link>
      <description>&lt;P&gt;In that case you'll have to use the Arcgis API for Python. Arcpy is mostly for managing a Pro instance and wrangling tools/data.&lt;/P&gt;&lt;P&gt;The general flow should be the same though.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2025 04:27:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1624921#M74400</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-06-19T04:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Add Google Maps as a basemap via Python</title>
      <link>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1625176#M74406</link>
      <description>&lt;P&gt;Replit found the solution: call the Google Maps satellite view as a basemap layer when creating a webmap object.&lt;BR /&gt;&lt;BR /&gt;# Create web map JSON with Google satellite as basemap&lt;BR /&gt;sat_url = "&lt;A href="https://mt1.google.com/vt/lyrs=y&amp;amp;x={col}&amp;amp;y={row}&amp;amp;z={level" target="_blank"&gt;https://mt1.google.com/vt/lyrs=y&amp;amp;x={col}&amp;amp;y={row}&amp;amp;z={level&lt;/A&gt;}"&lt;BR /&gt;webmap_json = {&lt;BR /&gt;"operationalLayers": operational_layers,&lt;BR /&gt;"baseMap": {&lt;BR /&gt;"baseMapLayers": [{&lt;BR /&gt;"id": "google_satellite",&lt;BR /&gt;"title": "Google Satellite",&lt;BR /&gt;"url": sat_url,&lt;BR /&gt;"layerType": "WebTiledLayer",&lt;BR /&gt;"templateUrl": sat_url.replace("{col}", "{x}").replace("{row}", "{y}").replace("{level}", "{z}"),&lt;BR /&gt;"visibility": True,&lt;BR /&gt;"opacity": 1,&lt;BR /&gt;"subDomains": ["mt0", "mt1", "mt2", "mt3"],&lt;BR /&gt;"copyright": "Google"&lt;BR /&gt;}],&lt;BR /&gt;"title": "Google Satellite"&lt;BR /&gt;},&lt;BR /&gt;"spatialReference": {&lt;BR /&gt;"wkid": 102100,&lt;BR /&gt;"latestWkid": 3857&lt;BR /&gt;},&lt;BR /&gt;"initialExtent": {&lt;BR /&gt;"xmin": -9548000,&lt;BR /&gt;"ymin": 1166000,&lt;BR /&gt;"xmax": -9542000,&lt;BR /&gt;"ymax": 1172000,&lt;BR /&gt;"spatialReference": {"wkid": 102100}&lt;BR /&gt;},&lt;BR /&gt;"version": "2.22"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# Create the web map item&lt;BR /&gt;create_item_url = "&lt;A href="https://www.arcgis.com/sharing/rest/content/users/self/addItem" target="_blank"&gt;https://www.arcgis.com/sharing/rest/content/users/self/addItem&lt;/A&gt;"&lt;BR /&gt;&lt;BR /&gt;item_data = {&lt;BR /&gt;'f': 'json',&lt;BR /&gt;'token': access_token,&lt;BR /&gt;'title': 'title1',&lt;BR /&gt;'type': 'Web Map',&lt;BR /&gt;'tags': 'test',&lt;BR /&gt;'snippet': 'Property map with 6 points',&lt;BR /&gt;'text': json.dumps(webmap_json)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;response = requests.post(create_item_url, data=item_data)&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2025 20:29:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1625176#M74406</guid>
      <dc:creator>AurelienRobert</dc:creator>
      <dc:date>2025-06-19T20:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Add Google Maps as a basemap via Python</title>
      <link>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1625692#M74419</link>
      <description>&lt;P&gt;Does google allow you to link to its maps from an application with other map sources? I think with 'StreetView' they specifically disallow that in the Terms of Service.&lt;BR /&gt;&lt;BR /&gt;I would be careful about grabbing map imagery from sources you don't have known licenses for, as it could also possibly be a copyright issue.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jun 2025 13:56:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-google-maps-as-a-basemap-via-python/m-p/1625692#M74419</guid>
      <dc:creator>TimWestern</dc:creator>
      <dc:date>2025-06-23T13:56:57Z</dc:date>
    </item>
  </channel>
</rss>

