How to set vactorTile Layer as costum basemap?

1193
3
Jump to solution
10-12-2016 04:30 AM
SebastianBosbach
New Contributor III

Hi everyone,

how can I set a custom vector tile layer as a basemap, so it will appear in the basemap dijit?

When I try to add vector layer as a basemap, it doesn't work because it seems a BaseMapLayer only works with tile based services.

Greetings Sebastian 

0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

You can add VectorTileLayer as a basemap to the basemapGallery as shown below. You need to specify styleUrl and type properties of the BasemapLayer. 

    var vtlayer = new BasemapLayer({
           type: "VectorTileLayer"
        });

        var vtlBasemap = new Basemap({
            layers: [vtlayer],
            title: "Xmas Template",
            thumbnailUrl:"images/basemap.png"
        });

Please use this working app to see how this is done. 

JS Bin - Collaborative JavaScript Debugging 

We will update the BasemapLayer documentation to show how to add VectorTileLayer as a basemap to the basemapGallery. 

Hope this helps,

-Undral

View solution in original post

0 Kudos
3 Replies
SebastianBosbach
New Contributor III

Dose nobody have a solution or suggestion to this problem?

I waited some api versions and as I see, there is still not way to ad a vector layer as a basemap.

Greetings Sebastian 

0 Kudos
UndralBatsukh
Esri Regular Contributor

Hi there, 

You can add VectorTileLayer as a basemap to the basemapGallery as shown below. You need to specify styleUrl and type properties of the BasemapLayer. 

    var vtlayer = new BasemapLayer({
           type: "VectorTileLayer"
        });

        var vtlBasemap = new Basemap({
            layers: [vtlayer],
            title: "Xmas Template",
            thumbnailUrl:"images/basemap.png"
        });

Please use this working app to see how this is done. 

JS Bin - Collaborative JavaScript Debugging 

We will update the BasemapLayer documentation to show how to add VectorTileLayer as a basemap to the basemapGallery. 

Hope this helps,

-Undral

0 Kudos
SebastianBosbach
New Contributor III

Hi, thank you so much Undral.

Your code works very well. The problem was, that this isn't documented in the api reference.

Also the above code only adds the layer to the Gallery, but not to the static "basemaps" object, which I also wanted to do. Because I also want to set my vector tile layer as the initial basemap.

So if anyone else got this problem, her is an example code to do this.

basemaps[basemap.id] = {
    baseMapLayers: [
        {url: basemap.url, type: "VectorTile"}
    ],
    title: basemap.title,
    thumbnailUrl: basemap.thumbnailUrl,
};

The important part is, that you have to set the type to "VectorTile" instead of "VectorTileLayer", wich is needed in the BasemapLayer object.

@Undral

I think it would be good to add this to the api reference. If this is somewhere in the reference, please show me where I could have found this, thanks.

best regards,

Sebastian