This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Specify a Custom Base Layer

The webmap function provides a selection of over a dozen base layers (basemaps) which provide a variety of geographic backdrops on which you can plot your data. See the webmap function for a complete list. In some cases, you might want to plot your data over a map of your own choosing. To do this, specify a custom base layer by using the addCustomBasemap function. The following example shows how to specify a high-resolution topographical map as a custom base layer.

  1. Specify the URL of the website that provides the map data. In this example, for better load balancing, the web map provides three servers that you can use: a, b, or c.

    url = 'a.tile.opentopomap.org';
    
  2. Define the name that you will use to specify the custom base layer programmatically. For example, you can use this name with the webmap command or, if you want to delete the custom map, with the removeCustomBasemap function.

    name = 'opentopomap';
  3. Create an attribution to display on the map that gives credit to the provider of the map data. Web map providers might define specific requirements for the attribution.

    copyright = char(uint8(169));
    attribution = [ ...
          "map data:  " + copyright + "OpenStreetMap contributors,SRTM", ...
          "map style: " + copyright + "OpenTopoMap (CC-BY-SA)"];
    
  4. Define the name that will appear in the Layer Manager to identify the custom base layer.

    displayName = 'Open Topo Map';
  5. Add the custom base layer to the list of base layers available through the Layer Manager. When you add a custom base layer, the addition is persistent between MATLAB sessions.

    addCustomBasemap(name,url,'Attribution',attribution,'DisplayName',displayName)
    
  6. Open a web map. Expand the Layer Manager and find the listing for the custom base layer in the list of base layers. To view the custom base layer, select the map in the Layer Manager. You can also specify the name you assigned to the map as an argument to the webmap function.

    webmap opentopomap
    

See Also

| |

Related Topics