UNPKG

vue-cesium

Version:
1 lines 9.19 kB
{"version":3,"file":"index.mjs","sources":["../../../../../../packages/components/providers/baidu/index.ts"],"sourcesContent":["/*\n * @Author: zouyaoji@https://github.com/zouyaoji\n * @Date: 2021-09-16 09:28:13\n * @LastEditTime: 2023-03-02 09:33:04\n * @LastEditors: zouyaoji 370681295@qq.com\n * @Description:\n * @FilePath: \\vue-cesium@next\\packages\\components\\providers\\baidu\\index.ts\n */\nimport { createCommentVNode, defineComponent, getCurrentInstance } from 'vue'\nimport type { PropType } from 'vue'\nimport type {\n ProjectionTransforms,\n VcComponentInternalInstance,\n VcComponentPublicInstance,\n VcImageryProvider,\n VcReadyObject,\n VcRectangle\n} from '@vue-cesium/utils/types'\nimport BaiduMapImageryProvider from './BaiduMapImageryProvider'\nimport { useProviders } from '@vue-cesium/composables'\nimport { url, rectangle, ellipsoid, tileDiscardPolicy, credit, minimumLevel, maximumLevel } from '@vue-cesium/utils/cesium-props'\nimport { kebabCase } from '@vue-cesium/utils/util'\nimport { providerEmits } from '@vue-cesium/utils/emits'\n\nexport const baiduImageryProviderProps = {\n ...url,\n ...rectangle,\n ...ellipsoid,\n ...tileDiscardPolicy,\n ...credit,\n ...minimumLevel,\n ...maximumLevel,\n projectionTransforms: {\n type: [Boolean, Object] as PropType<ProjectionTransforms>,\n default: () => {\n return {\n from: 'BD09',\n to: 'WGS84'\n }\n }\n },\n scale: {\n type: String as PropType<'1' | '2'>,\n default: '2'\n },\n ak: {\n type: String,\n default: '5ieMMexWmzB9jivTq6oCRX9j'\n },\n subdomains: {\n type: Array as PropType<string[]>,\n default: () => ['0', '1', '2', '3']\n },\n // https://lbsyun.baidu.com/custom/list.htm\n mapStyle: {\n type: String as PropType<\n | 'img'\n | 'vec'\n | 'traffic'\n | 'normal'\n | 'light'\n | 'dark'\n | 'redalert'\n | 'googlelite'\n | 'grassgreen'\n | 'midnight'\n | 'pink'\n | 'darkgreen'\n | 'bluish'\n | 'grayscale'\n | 'hardedge'\n >,\n default: 'vec' // img vec traffic normal light dark redalert googlelite grassgreen midnight pink darkgreen bluish grayscale hardedge\n },\n qt: {\n type: String as PropType<'tile' | 'vtile'>,\n default: 'vtile'\n },\n styles: {\n type: String as PropType<'sl' | 'pl' | 'ph'>, // sl 背景透明 pl 正常 ph 大字体\n default: 'pl'\n },\n showtext: {\n type: String as PropType<'0' | '1'>, // 0 不显示, 1 显示\n default: '1'\n }\n}\nexport default defineComponent({\n name: 'VcImageryProviderBaidu',\n props: baiduImageryProviderProps,\n emits: providerEmits,\n setup(props, ctx) {\n // state\n const instance = getCurrentInstance() as VcComponentInternalInstance\n instance.cesiumClass = 'BaiduMapImageryProvider'\n const providersState = useProviders(props, ctx, instance)\n\n if (undefined === providersState) {\n return\n }\n // methods\n instance.createCesiumObject = async () => {\n Cesium.BaiduMapImageryProvider = Cesium.BaiduMapImageryProvider || BaiduMapImageryProvider\n if (providersState.unwatchFns.length === 0) {\n providersState.setPropsWatcher(true)\n }\n const options = providersState.transformProps(props)\n return new Cesium.BaiduMapImageryProvider(options)\n }\n\n return () => createCommentVNode(kebabCase(instance.proxy?.$options.name || ''))\n }\n})\n\nexport type VcImageryProviderBaiduProps = {\n /**\n * The URL of the Baidu Imagery service.\n */\n url?: string | Cesium.Resource\n /**\n * The rectangle of the layer. This parameter is ignored when accessing a tiled layer.\n */\n rectangle?: VcRectangle\n /**\n * The ellipsoid. If the tilingScheme is specified and used, this parameter is ignored and the tiling scheme's ellipsoid is used instead. If neither parameter is specified, the WGS84 ellipsoid is used.\n */\n ellipsoid?: Cesium.Ellipsoid\n /**\n * The policy that determines if a tile is invalid and should be discarded. If this value is not specified, a default DiscardMissingTileImagePolicy is used for tiled map servers, and a NeverTileDiscardPolicy is used for non-tiled map servers. In the former case, we request tile 0,0 at the maximum tile level and check pixels (0,0), (200,20), (20,200), (80,110), and (160, 130). If all of these pixels are transparent, the discard check is disabled and no tiles are discarded. If any of them have a non-transparent color, any tile that has the same values in these pixel locations is discarded. The end result of these defaults should be correct tile discarding for a standard ArcGIS Server. To ensure that no tiles are discarded, construct and pass a NeverTileDiscardPolicy for this parameter.\n */\n tileDiscardPolicy?: Cesium.DiscardMissingTileImagePolicy | Cesium.NeverTileDiscardPolicy\n /**\n * A credit for the data source, which is displayed on the canvas. This parameter is ignored when accessing a tiled server.\n */\n credit?: string | Cesium.Credit\n /**\n * The minimumLevel tile level to request, or undefined if there is no minimumLevel. This parameter is ignored when accessing a tiled server.\n */\n minimumLevel?: number\n /**\n * The maximum tile level to request, or undefined if there is no maximum. This parameter is ignored when accessing a tiled server.\n */\n maximumLevel?: number\n /**\n * Specify the baidumap key\n */\n ak?: string\n /**\n * Specify the service polling parameters.\n * Default value: ['0', '1', '2', '3']\n */\n subdomains?: string[]\n /**\n * Specify the map style\n */\n mapStyle?:\n | 'img'\n | 'vec'\n | 'traffic'\n | 'normal'\n | 'light'\n | 'dark'\n | 'redalert'\n | 'googlelite'\n | 'grassgreen'\n | 'midnight'\n | 'pink'\n | 'darkgreen'\n | 'bluish'\n | 'grayscale'\n | 'hardedge'\n /**\n * Specify tile request type.\n * Default value: vtile\n */\n qt?: 'tile' | 'vtile'\n /**\n * Specify tile styles.\n * Default value: pl\n */\n styles?: 'sl' | 'pl'\n /**\n * Specify the scale.\n * Default value: 2\n */\n scale?: '1' | '2'\n /**\n * Specify the projection transformation parameters. such as { from: 'BD09', to: 'WGS84' }\n */\n projectionTransforms?: ProjectionTransforms\n /**\n * Triggers before the VcImageryProviderArcgis is loaded.\n */\n onBeforeLoad?: (instance: VcComponentInternalInstance) => void\n /**\n * Triggers when the VcImageryProviderArcgis is successfully loaded.\n */\n onReady?: (readyObject: VcReadyObject) => void\n /**\n * Triggers when the component load failed.\n */\n onUnready?: (e: any) => void\n /**\n * Triggers when the VcImageryProviderArcgis is destroyed.\n */\n onDestroyed?: (instance: VcComponentInternalInstance) => void\n /**\n * Triggers when the imagery provider encounters an asynchronous error.\n */\n onErrorEvent?: (evt: Cesium.TileProviderError) => void\n /**\n * Triggers when the provider is ready for use.\n */\n onReadyPromise?: (evt: boolean | VcImageryProvider, viewer: Cesium.Viewer, instance: VcComponentPublicInstance) => void\n}\n\nexport type VcImageryProviderBaiduRef = VcComponentPublicInstance<VcImageryProviderBaiduProps>\n"],"names":[],"mappings":";;;;;;;;;AAwBO,MAAM,yBAA4B,GAAA;AAAA,EACvC,GAAG,GAAA;AAAA,EACH,GAAG,SAAA;AAAA,EACH,GAAG,SAAA;AAAA,EACH,GAAG,iBAAA;AAAA,EACH,GAAG,MAAA;AAAA,EACH,GAAG,YAAA;AAAA,EACH,GAAG,YAAA;AAAA,EACH,oBAAsB,EAAA;AAAA,IACpB,IAAA,EAAM,CAAC,OAAA,EAAS,MAAM,CAAA;AAAA,IACtB,SAAS,MAAM;AACb,MAAO,OAAA;AAAA,QACL,IAAM,EAAA,MAAA;AAAA,QACN,EAAI,EAAA,OAAA;AAAA,OACN,CAAA;AAAA,KACF;AAAA,GACF;AAAA,EACA,KAAO,EAAA;AAAA,IACL,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,GAAA;AAAA,GACX;AAAA,EACA,EAAI,EAAA;AAAA,IACF,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,0BAAA;AAAA,GACX;AAAA,EACA,UAAY,EAAA;AAAA,IACV,IAAM,EAAA,KAAA;AAAA,IACN,SAAS,MAAM,CAAC,GAAK,EAAA,GAAA,EAAK,KAAK,GAAG,CAAA;AAAA,GACpC;AAAA;AAAA,EAEA,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,MAAA;AAAA,IAiBN,OAAS,EAAA,KAAA;AAAA;AAAA,GACX;AAAA,EACA,EAAI,EAAA;AAAA,IACF,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,OAAA;AAAA,GACX;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,MAAA;AAAA;AAAA,IACN,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EACA,QAAU,EAAA;AAAA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