简介
地图上大部分的动态显示效果吗,如图标,区域点,线,面等都是基于layer来实现的,
mapbox中的layer主要存在以下几种类型:background, fill, line, symbol, raster, circle, fill-extrusion, heatmap, hillshade。其中只有background的显示不依赖source。
background
map.loadImage('https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Cat_silhouette.svg/64px-Cat_silhouette.svg.png', function(err, image) {
// Throw an error if something went wrong
if (err) throw err;
// Declare the image
map.addImage('pattern', image);
// Use it
map.addLayer({
"id": "pattern-layer",
"type": "background",
"paint": {
"background-pattern": "pattern"
}
});
});
background 类型的图层,不需要传入source,background-pattern接受一个地图