美文网首页
cesium 图层构建的那些事 (四)

cesium 图层构建的那些事 (四)

作者: haibalai | 来源:发表于2022-04-28 09:03 被阅读0次

    我们通过构建百度地图容器类

    ```javascript

    import {ImageryLayer} from "../ImageryLayer";

    const urls:any = {

    digital:"http://online{s}.map.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles=pl&scaler=1&p=1",//电子地图

    image:"http://shangetu{s}.map.bdimg.com/it/u=x={x};y={y};z={z};v=009;type=sate&fm=46",//影像地图

    mark:"http://online{s}.map.bdimg.com/tile/?qt=tile&x={x}&y={y}&z={z}&styles=sl&v=020",//注记

    xxx:'http://api{s}.map.bdimg.com/customimage/tile?&x={x}&y={y}&z={z}&scale=1&customid={style}'

    }

    //百度地图

    export class BDImageryLayer extends ImageryLayer{

    public imageryProvider:any;//影像提供者

    constructor(option:any={}){

    super(option.name);

    const url:string = urls[option.mold] || urls.digital;

    option = {url,...option};

    this.type = "BDImageryLayer";//重写类型

    this.imageryProvider = new BaiduImageryProvider(option);

    this.cesiumLayer = new Cesium.ImageryLayer(this.imageryProvider);

    }

    }

    class BaiduImageryProvider{

    public _errorEvent:any;

    public _tileWidth:any;

    public _tileHeight:any;

    public _maximumLevel:any;

    public _minimumLevel:any;

    public _tilingScheme:any;

    public _rectangle:any;

    public _tileDiscardPolicy:any;

    public _resource:any;

    public _credit:any;

    public _readyPromise:any;

    constructor(options:any){

    this._errorEvent = new Cesium.Event();

    this._tileWidth = 256;

    this._tileHeight = 256;

    this._maximumLevel = 18;

    this._minimumLevel = 1;

    var southwestInMeters = new Cesium.Cartesian2(-33554054, -33746824);

    var northeastInMeters = new Cesium.Cartesian2(33554054, 33746824);

    this._tilingScheme = new Cesium.WebMercatorTilingScheme({

    rectangleSouthwestInMeters: southwestInMeters,

    rectangleNortheastInMeters: northeastInMeters

    });

    this._rectangle = this._tilingScheme.rectangle;

    var resource = Cesium.Resource.createIfNeeded(options.url);

    this._resource = resource;

    this._tileDiscardPolicy = undefined;

     更多参考 https://xiaozhuanlan.com/topic/7254138609

    相关文章

      网友评论

          本文标题:cesium 图层构建的那些事 (四)

          本文链接:https://www.haomeiwen.com/subject/xsbryrtx.html