Spatial Analysis in 2025: Key Trends Report
| Download Now
CARTO
Platform
Overview
Visualization
Analytics
App Development
Data Enrichment
AI Agents
Enterprise & Security
Pricing
CARTO for
Google Cloud
AWS
Azure
Snowflake
Databricks
Oracle
Solutions
By Industry
By Use Case
By Role
Telecoms
Icon/indus/Insurance-menu
Icon/indus/Insurance-menu-mobile
Insurance
Logistics
Real Estate
Financial Services
Retail
Marketing & Advertising
Mobility
All industries
Network Deployment
Catastrophe Modeling
Fraud Detection
Market Analysis
Environmental Management
Site Selection
Geomarketing
Data Monetization
IoT Analytics
Supply Chain Optimization
Healthcare Analytics
Territory Planning
All use cases
Data Analyst
Data Scientist
GIS Professional
Developer
Customers
Resources
Learn
Documentation
CARTO Academy
Blog
Reports
Glossary
Connect
Events
Partners
Webinars
Log inRequest a demo
Try for free
2050-01-01
1990-01-01
"ES", "GB"

This content applies to a previous version of CARTO

In October 2021 we released a new version of our platform. You can find the latest documentation at docs.carto.com

Back to Help Center

Manipulating Your Data with CARTO Editor

Learn how to manipulate your data with CARTO Editor.

How can I show only one country/area/region on a map?

If you would like to have a map featuring only one region or a given set of boundaries, you can define this with a custom SQL query. From the CARTO Editor, click SQL and apply the following statement:

SELECT * FROM tablename WHERE name = 'country/region/area'

Create a new dataset from the query results and choose a solid color as your basemap. This ensures that only your selected area is displayed.

Tip: If you are comfortable working with the viz.json object, you can add custom code to your js file to set the zoom level and disable panning.

How can I hide a subLayer of a Named Map?

By using the MAPS API, you can create Named Maps, which enable you to create shareable maps from private data. The map configurations are stored on the server and given a unique name.

In order to hide a subLayer of a Named Map, there are two requirements; you must define internal placeholders objects in the map configuration file, and add a WHERE clause to define the placeholder variables in each subLayer.

  1. Instantiate the Named Map template with CARTO.js
  2. Create a visualization at runtime
  3. Hide the subLayer

Controlling the subLayer visibility requires that you use internal placeholders to define each layer in the WHERE clause:

layer.getSubLayer(0).show() // set the placeholder layer0=1
layer.getSubLayer(0).hide() // set layer0=0

Example Named Map configuration with placeholders:

{
  "version": "0.0.1",
  "name": "buques",
  "auth": {
    "method": "token",
    "valid_tokens": []
  },
  "placeholders" : {
    "layer0": {
      "type": "number",
      "default": 1
    },
    "layer1": {
      "type": "number",
      "default": 1
    }
  },
  "layergroup": {
    "version": "1.0.1",
    "layers": [
      {
        "type": "cartodb",
        "options": {
          "cartocss_version": "2.1.1",
          "cartocss": "...",
          "sql": " SELECT * FROM t0 where <%= layer0 %> = 1",
          "interactivity": "..."
        }
      },
      {
        "type": "cartodb",
        "options": {
          "cartocss_version": "2.1.1",
          "cartocss": "...",
          "sql": "SELECT * FROM t1 where <%= layer1 %> = 1",
          "interactivity": "cartodb_id"
        }
      }
    ]
  }
}

How to create a password-protected Named Map?

This high-level workflow describes how to create a password-protected Named Map, using the CARTO Engine APIs.

  1. Upload a dataset with the Import API, by defining the api_key and setting the dataset to private on import.
  2. Create the config.json file for a Named Map, and include:
    • an SQL query to select the private dataset
    • set the auth method to token with one or more auth_tokens (passwords)
    • Post the config.json file to the Maps API to instantiate the Named Map definition
  3. Use the CARTO.js createLayer function to create the Named Map, using the layer.setAuthToken method to set the password.
CARTO
carto-logo
  • Platform

  • Overview

  • Visualization

  • Analytics

  • App Development

  • Data Enrichment

  • Security & Governance

  • Gen AI

  • Pricing

  • Solutions

  • Data Analyst

  • Developer

  • Data Scientist

  • GIS Professional

  • By Industry

  • By Use Case

  • Resources

  • Customer Stories

  • Blog

  • Glossary

  • Documentation

  • Academy

  • Reports

  • Events

  • Webinars

  • Partners

  • Company

  • About us

  • Newsroom

  • Careers

  • Brand

  • Grants

Unlock the power of spatial analysis.

youtube logofacebook logotwitter logolinkedin logo

© CARTO 2024

Terms

Privacy Notice

Whistleblower Form